diff --git a/Server/SchoolBusAPI/SchoolBusAPI.csproj b/Server/SchoolBusAPI/SchoolBusAPI.csproj
index c5680a53..7709346c 100644
--- a/Server/SchoolBusAPI/SchoolBusAPI.csproj
+++ b/Server/SchoolBusAPI/SchoolBusAPI.csproj
@@ -9,7 +9,7 @@
Ministry of Transportation and Infrastructure
The API server for the schoolbus inspection application.
Copyright© 2017, Province of British Columbia.
- 2.0.6
+ 2.0.7
diff --git a/Server/SchoolBusAPI/Services/CCWDataService.cs b/Server/SchoolBusAPI/Services/CCWDataService.cs
index aec55204..57c45b75 100644
--- a/Server/SchoolBusAPI/Services/CCWDataService.cs
+++ b/Server/SchoolBusAPI/Services/CCWDataService.cs
@@ -325,6 +325,19 @@ public CCWData GetCCW(string regi, string plate, string vin, string userId, stri
}
}
+ // TH-121015
+ DateTime dateFetched = DateTime.SpecifyKind(ccwdata.DateFetched.GetValueOrDefault(), DateTimeKind.Unspecified);
+ DateTime icbcVipExpiry = DateTime.SpecifyKind(ccwdata.ICBCCVIPExpiry.GetValueOrDefault(), DateTimeKind.Unspecified);
+ DateTime nscPolicyEffectiveDate = DateTime.SpecifyKind(ccwdata.NSCPolicyEffectiveDate.GetValueOrDefault(), DateTimeKind.Unspecified);
+ DateTime nscPolicyExpiryDate = DateTime.SpecifyKind(ccwdata.NSCPolicyExpiryDate.GetValueOrDefault(), DateTimeKind.Unspecified);
+ DateTime nscPolicyStatusDate = DateTime.SpecifyKind(ccwdata.NSCPolicyStatusDate.GetValueOrDefault(), DateTimeKind.Unspecified);
+ ccwdata.DateFetched = dateFetched;
+ ccwdata.ICBCCVIPExpiry = icbcVipExpiry;
+ ccwdata.NSCPolicyEffectiveDate = nscPolicyEffectiveDate;
+ ccwdata.NSCPolicyExpiryDate = nscPolicyExpiryDate;
+ ccwdata.NSCPolicyStatusDate = nscPolicyStatusDate;
+
+
if (ccwdata.Id > 0)
{
var bus = _context.SchoolBuss.FirstOrDefault(x => x.CCWDataId == ccwdata.Id);
diff --git a/Server/SchoolBusAPI/Services/CurrentUserService.cs b/Server/SchoolBusAPI/Services/CurrentUserService.cs
index 08a8031d..9994728c 100644
--- a/Server/SchoolBusAPI/Services/CurrentUserService.cs
+++ b/Server/SchoolBusAPI/Services/CurrentUserService.cs
@@ -255,6 +255,8 @@ public virtual IActionResult UsersCurrentGetAsync()
DateTime today = DateUtils.ConvertPacificToUtcTime(
new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 0, 0, 0));
+ // TH-120363
+ today = DateTime.SpecifyKind(today, DateTimeKind.Unspecified);
DateTime utcDateTo = today.AddDays(31).AddSeconds(-1);
DateTime dateTo = DateTime.SpecifyKind(utcDateTo, DateTimeKind.Unspecified);
diff --git a/Server/SchoolBusAPI/Services/InspectionService.cs b/Server/SchoolBusAPI/Services/InspectionService.cs
index bd72b77a..8be8d334 100644
--- a/Server/SchoolBusAPI/Services/InspectionService.cs
+++ b/Server/SchoolBusAPI/Services/InspectionService.cs
@@ -197,6 +197,9 @@ public virtual IActionResult InspectionsIdPutAsync(int id, Inspection item)
var exists = _context.Inspections.Any(a => a.Id == id);
if (exists && id == item.Id)
{
+ item.CreatedDate = DateTime.SpecifyKind(item.CreatedDate, DateTimeKind.Unspecified);
+ item.InspectionDate = DateTime.SpecifyKind(item.InspectionDate, DateTimeKind.Unspecified);
+ item.PreviousNextInspectionDate = DateTime.SpecifyKind(item.PreviousNextInspectionDate.GetValueOrDefault(), DateTimeKind.Unspecified);
_context.Inspections.Update(item);
// Save the changes
_context.SaveChanges();
@@ -258,6 +261,7 @@ public virtual IActionResult InspectionsPostAsync(Inspection item)
}
var exists = _context.Inspections.Any(a => a.Id == item.Id);
+ item.InspectionDate = DateTime.SpecifyKind(item.InspectionDate, DateTimeKind.Unspecified);
if (exists)
{
_context.Inspections.Update(item);
@@ -269,6 +273,8 @@ public virtual IActionResult InspectionsPostAsync(Inspection item)
{
// Inspection has a special field, createdDate which is set to now.
item.CreatedDate = DateTime.UtcNow;
+ // TH-120363
+ item.CreatedDate = DateTime.SpecifyKind(item.CreatedDate, DateTimeKind.Unspecified);
_context.Inspections.Add(item);
}
_context.SaveChanges();
diff --git a/Server/SchoolBusAPI/Services/SchoolBusOwnerService.cs b/Server/SchoolBusAPI/Services/SchoolBusOwnerService.cs
index 687267b3..bf67f449 100644
--- a/Server/SchoolBusAPI/Services/SchoolBusOwnerService.cs
+++ b/Server/SchoolBusAPI/Services/SchoolBusOwnerService.cs
@@ -452,6 +452,7 @@ public virtual IActionResult SchoolbusownersIdPutAsync(int id, SchoolBusOwner bo
.OrderByDescending(x => x.NextInspectionDate)
.First();
result = schoolbus.NextInspectionDate;
+ if (schoolbus.NextInspectionDate != null && schoolbus.NextInspectionDate.Value.Year == 1) { result = null; }
}
return result;
}
@@ -531,6 +532,7 @@ public virtual IActionResult SchoolbusownersPostAsync(SchoolBusOwner body)
{
AdjustSchoolBusOwner(body);
body.DateCreated = DateTime.UtcNow;
+ body.DateCreated = DateTime.SpecifyKind(body.DateCreated, DateTimeKind.Unspecified);
_context.SchoolBusOwners.Add(body);
_context.SaveChanges();
return new ObjectResult(body);
diff --git a/Server/SchoolBusAPI/Services/SchoolBusService.cs b/Server/SchoolBusAPI/Services/SchoolBusService.cs
index cb6b04d0..98660f50 100644
--- a/Server/SchoolBusAPI/Services/SchoolBusService.cs
+++ b/Server/SchoolBusAPI/Services/SchoolBusService.cs
@@ -292,6 +292,9 @@ private void AdjustSchoolBus(SchoolBus item)
item.CCWData = null;
}
}
+
+ item.NextInspectionDate = DateTime.SpecifyKind(item.NextInspectionDate.GetValueOrDefault(), DateTimeKind.Unspecified);
+ item.PermitIssueDate = DateTime.SpecifyKind(item.PermitIssueDate.GetValueOrDefault(), DateTimeKind.Unspecified);
}
}
@@ -316,6 +319,14 @@ public virtual IActionResult SchoolbusesIdGetAsync(int id)
.Include(x => x.Inspector)
.Include(x => x.CCWData)
.First(a => a.Id == id);
+ if (result.PermitIssueDate != null && result.PermitIssueDate.Value.Year == 1)
+ {
+ result.PermitIssueDate = null;
+ }
+ if (result.NextInspectionDate != null && result.NextInspectionDate.Value.Year == 1)
+ {
+ result.NextInspectionDate = null;
+ }
return new ObjectResult(result);
}
else
@@ -844,6 +855,7 @@ public virtual IActionResult SchoolbusesIdNewpermitPutAsync(int id)
item.PermitNumber = permit;
item.PermitIssueDate = DateTime.UtcNow;
+ item.PermitIssueDate = DateTime.SpecifyKind(item.PermitIssueDate.GetValueOrDefault(), DateTimeKind.Unspecified);
_context.SchoolBuss.Update(item);
_context.SaveChanges();
@@ -964,6 +976,8 @@ public IActionResult SchoolbusesSearchGetAsync(int?[] districts, int?[] inspecto
{
var dateFrom = DateUtils.ConvertPacificToUtcTime(
new DateTime(sDate.Year, sDate.Month, sDate.Day, 0, 0, 0));
+ // TH-120363
+ dateFrom = DateTime.SpecifyKind(dateFrom, DateTimeKind.Unspecified);
data = data.Where(x => x.NextInspectionDate >= dateFrom);
}
@@ -974,12 +988,25 @@ public IActionResult SchoolbusesSearchGetAsync(int?[] districts, int?[] inspecto
new DateTime(eDate.Year, eDate.Month, eDate.Day, 0, 0, 0))
.AddDays(1)
.AddSeconds(-1);
+ // TH-120363
+ dateTo = DateTime.SpecifyKind(dateTo, DateTimeKind.Unspecified);
data = data.Where(x => x.NextInspectionDate <= dateTo);
}
}
var result = data.ToList();
+ foreach (var item in result)
+ {
+ if (item.NextInspectionDate.HasValue && item.NextInspectionDate.Value.Year == 1)
+ {
+ item.NextInspectionDate = null;
+ }
+ if (item.PermitIssueDate.HasValue && item.PermitIssueDate.Value.Year == 1)
+ {
+ item.PermitIssueDate = null;
+ }
+ }
return new ObjectResult(result);
}
diff --git a/Server/SchoolBusAPI/Services/UserService.cs b/Server/SchoolBusAPI/Services/UserService.cs
index 018233f8..daf3173d 100644
--- a/Server/SchoolBusAPI/Services/UserService.cs
+++ b/Server/SchoolBusAPI/Services/UserService.cs
@@ -325,12 +325,16 @@ public virtual IActionResult CreateUserRole(int userId, UserRoleViewModel item)
user.UserRoles = new List();
}
+ // TH - 121015
+ DateTime effectiveDate = DateTime.SpecifyKind(item.EffectiveDate, DateTimeKind.Unspecified);
+ DateTime expiryDate = DateTime.SpecifyKind(item.ExpiryDate.GetValueOrDefault(), DateTimeKind.Unspecified);
+
// create a new UserRole based on the view model.
user.UserRoles.Add(new UserRole
{
Role = _context.Roles.First(x => x.Id == item.RoleId),
- EffectiveDate = item.EffectiveDate,
- ExpiryDate = item.ExpiryDate
+ EffectiveDate = effectiveDate,
+ ExpiryDate = expiryDate
}
);
@@ -352,9 +356,10 @@ public virtual IActionResult UpdateUserRole(int userId, int userRoleId, UserRole
var userRole = _context.UserRoles
.Include(x => x.Role)
- .First(x => x.Id == item.Id);
-
- userRole.ExpiryDate = item.ExpiryDate;
+ .First(x => x.Id == item.Id);
+ // TH-121015
+ DateTime expiryDate = DateTime.SpecifyKind(item.ExpiryDate.GetValueOrDefault(), DateTimeKind.Unspecified);
+ userRole.ExpiryDate = expiryDate;
_context.SaveChanges();
return new StatusCodeResult(201);
diff --git a/client/src/js/Keycloak.js b/client/src/js/Keycloak.js
index 7395ef1f..d218043f 100644
--- a/client/src/js/Keycloak.js
+++ b/client/src/js/Keycloak.js
@@ -11,8 +11,17 @@ const keycloakConfig = {
export const keycloak = Keycloak(keycloakConfig);
export const init = (onSuccess) => {
- keycloak.init({ onLoad: 'login-required', promiseType: 'native', pkceMethod: 'S256' }).then((authenticated) => {
+ keycloak.init({
+ onLoad: 'login-required',
+ promiseType: 'native',
+ pkceMethod: 'S256',
+ }).then((authenticated) => {
if (authenticated && onSuccess) {
+ // Clean up the URL by removing any unwanted query parameters like 'iss'
+ const url = window.location.href;
+ const cleanUrl = url.split('&iss=')[0]; // Remove everything after &iss=
+ // clean the URL without refreshing the page
+ window.history.replaceState(null, null, cleanUrl);
onSuccess();
}
});
diff --git a/client/src/js/views/SchoolBusesDetail.jsx b/client/src/js/views/SchoolBusesDetail.jsx
index 4ab66ab4..842861e1 100644
--- a/client/src/js/views/SchoolBusesDetail.jsx
+++ b/client/src/js/views/SchoolBusesDetail.jsx
@@ -473,8 +473,14 @@ class SchoolBusesDetail extends React.Component {
)}
{bus.permitIssueDate && (
+ //
+ // (Issued: {formatDateTime(bus.permitIssueDate, Constant.DATE_SHORT_MONTH_DAY_YEAR)})
+ //
+
- (Issued: {formatDateTime(bus.permitIssueDate, Constant.DATE_SHORT_MONTH_DAY_YEAR)})
+ {bus.permitIssueDate && bus.permitIssueDate.includes("0001-01-01")
+ ? ""
+ : "(Issued: " + formatDateTime(bus.permitIssueDate, Constant.DATE_SHORT_MONTH_DAY_YEAR) + ")"}
)}
@@ -693,20 +699,48 @@ class SchoolBusesDetail extends React.Component {
{ccw.nscPolicyNumber}
-
+ {/*
{formatDateTime(ccw.nscPolicyStatusDate, Constant.DATE_SHORT_MONTH_DAY_YEAR)}
+ */}
+
+ {ccw.nscPolicyStatusDate && ccw.nscPolicyStatusDate.includes("0001-01-01")
+ ? ""
+ : formatDateTime(ccw.nscPolicyStatusDate, Constant.DATE_SHORT_MONTH_DAY_YEAR)}
+
+
{ccw.nscPolicyStatus}
-
+ {/*
{formatDateTime(ccw.nscPolicyEffectiveDate, Constant.DATE_SHORT_MONTH_DAY_YEAR)}
+ */}
+
+
+
+ {ccw.nscPolicyEffectiveDate && ccw.nscPolicyEffectiveDate.includes("0001-01-01")
+ ? ""
+ : formatDateTime(ccw.nscPolicyEffectiveDate, Constant.DATE_SHORT_MONTH_DAY_YEAR)}
-
+
+
+
+
+ {/*
{formatDateTime(ccw.nscPolicyExpiryDate, Constant.DATE_SHORT_MONTH_DAY_YEAR)}
+ */}
+
+
+ {ccw.nscPolicyExpiryDate && ccw.nscPolicyExpiryDate.includes("0001-01-01")
+ ? ""
+ : formatDateTime(ccw.nscPolicyExpiryDate, Constant.DATE_SHORT_MONTH_DAY_YEAR)}
+
+
+
+
{ccw.nscPlateDecal}
@@ -913,7 +947,9 @@ class SchoolBusesDetail extends React.Component {
{ccw.icbcFleetUnitNo}
- {formatDateTime(ccw.icbccvipExpiry, Constant.DATE_SHORT_MONTH_DAY_YEAR)}
+ {ccw.icbccvipExpiry && ccw.icbccvipExpiry.includes("0001-01-01")
+ ? ""
+ : formatDateTime(ccw.icbccvipExpiry, Constant.DATE_SHORT_MONTH_DAY_YEAR)}
{ccw.icbcNotesAndOrders}