Skip to content

Commit

Permalink
TH-121015: fix for user roles adding failure and ccwdata fetching error
Browse files Browse the repository at this point in the history
  • Loading branch information
bcgov-brwang committed Sep 18, 2024
1 parent bd53fc9 commit d1a4acb
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
13 changes: 13 additions & 0 deletions Server/SchoolBusAPI/Services/CCWDataService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
15 changes: 10 additions & 5 deletions Server/SchoolBusAPI/Services/UserService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -325,12 +325,16 @@ public virtual IActionResult CreateUserRole(int userId, UserRoleViewModel item)
user.UserRoles = new List<UserRole>();
}

// 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
}
);

Expand All @@ -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);
Expand Down

0 comments on commit d1a4acb

Please sign in to comment.