From f434983ca3bf5e1a27767568cc51686b19e3a765 Mon Sep 17 00:00:00 2001 From: zgong-gov Date: Thu, 28 Sep 2023 19:28:54 -0700 Subject: [PATCH] Wrap DateTimes with DateTimeKind.Utc --- .../Controllers/EquipmentController.cs | 20 +++-- Server/HetsApi/Controllers/OwnerController.cs | 51 +++++++++--- .../HetsApi/Controllers/ProjectController.cs | 6 +- .../Controllers/RentalAgreementController.cs | 83 ++++++++++++------- .../Controllers/RentalRequestController.cs | 75 +++++++++++------ .../HetsApi/Controllers/ReportController.cs | 6 +- Server/HetsApi/Controllers/UserController.cs | 52 ++++++++---- Server/HetsApi/Model/AitReport.cs | 13 +-- .../Entities/DbAppContextExtension.cs | 5 +- Server/HetsData/Helpers/EquipmentHelper.cs | 4 +- Server/HetsData/Helpers/OwnerHelper.cs | 9 +- Server/HetsData/Helpers/ProjectHelper.cs | 3 +- .../HetsData/Helpers/RentalAgreementHelper.cs | 5 +- .../HetsData/Helpers/RentalRequestHelper.cs | 8 +- Server/HetsData/Helpers/TimeRecordHelper.cs | 8 +- .../HetsData/Repositories/OwnerRepository.cs | 3 +- .../Repositories/RentalRequestRepository.cs | 12 ++- 17 files changed, 243 insertions(+), 120 deletions(-) diff --git a/Server/HetsApi/Controllers/EquipmentController.cs b/Server/HetsApi/Controllers/EquipmentController.cs index cce1f3151..a4ce1f344 100644 --- a/Server/HetsApi/Controllers/EquipmentController.cs +++ b/Server/HetsApi/Controllers/EquipmentController.cs @@ -292,25 +292,31 @@ public virtual ActionResult EquipmentIdPut([FromRoute]int id, [Fro // update equipment record equipment.ConcurrencyControlNumber = item.ConcurrencyControlNumber; - equipment.ApprovedDate = item.ApprovedDate; + if (item.ApprovedDate is DateTime approvedDateUtc) + { + equipment.ApprovedDate = DateUtils.AsUTC(approvedDateUtc); + } equipment.EquipmentCode = item.EquipmentCode; equipment.Make = item.Make; equipment.Model = item.Model; equipment.Operator = item.Operator; - equipment.ReceivedDate = item.ReceivedDate; + equipment.ReceivedDate = DateUtils.AsUTC(item.ReceivedDate); equipment.LicencePlate = item.LicencePlate; equipment.SerialNumber = item.SerialNumber; equipment.Size = item.Size; equipment.YearsOfService = item.YearsOfService; equipment.Year = item.Year; - equipment.LastVerifiedDate = item.LastVerifiedDate; + equipment.LastVerifiedDate = DateUtils.AsUTC(item.LastVerifiedDate); equipment.IsSeniorityOverridden = item.IsSeniorityOverridden; equipment.SeniorityOverrideReason = item.SeniorityOverrideReason; equipment.Type = item.Type; equipment.ServiceHoursLastYear = item.ServiceHoursLastYear; equipment.ServiceHoursTwoYearsAgo = item.ServiceHoursTwoYearsAgo; equipment.ServiceHoursThreeYearsAgo = item.ServiceHoursThreeYearsAgo; - equipment.SeniorityEffectiveDate = item.SeniorityEffectiveDate; + if (item.SeniorityEffectiveDate is DateTime seniorityEffectiveDateUtc) + { + equipment.SeniorityEffectiveDate = DateUtils.AsUTC(seniorityEffectiveDateUtc); + } equipment.LicencedGvw = item.LicencedGvw; equipment.LegalCapacity = item.LegalCapacity; equipment.PupLegalCapacity = item.PupLegalCapacity; @@ -1207,7 +1213,7 @@ public virtual ActionResult> EquipmentIdAttachmentsGet([Fro if (attachment != null) { attachment.FileSize = attachment.FileContents.Length; - attachment.LastUpdateTimestamp = attachment.AppLastUpdateTimestamp; + attachment.LastUpdateTimestamp = DateUtils.AsUTC(attachment.AppLastUpdateTimestamp); attachment.LastUpdateUserid = attachment.AppLastUpdateUserid; // don't send the file content @@ -1601,7 +1607,7 @@ private int GetLastCalledEquipmentId( { try { - fiscalStart = DateUtils.AsUTC(fiscalStart); + DateTime fiscalStartUtc = DateUtils.AsUTC(fiscalStart); // HETS-824 = BVT - Corrections to Seniority List PDF // * This column should contain "Y" against the equipment that @@ -1617,7 +1623,7 @@ private int GetLastCalledEquipmentId( .FirstOrDefault(x => x.RentalRequest.DistrictEquipmentTypeId == districtEquipmentTypeId && x.RentalRequest.LocalAreaId == localAreaId - && x.RentalRequest.AppCreateTimestamp >= fiscalStart + && x.RentalRequest.AppCreateTimestamp >= fiscalStartUtc && x.Equipment.BlockNumber == currentBlock && x.WasAsked == true && x.IsForceHire != true); diff --git a/Server/HetsApi/Controllers/OwnerController.cs b/Server/HetsApi/Controllers/OwnerController.cs index 796a8d466..fc2d5b452 100644 --- a/Server/HetsApi/Controllers/OwnerController.cs +++ b/Server/HetsApi/Controllers/OwnerController.cs @@ -244,10 +244,16 @@ public virtual ActionResult OwnersIdPut([FromRoute]int id, [FromBody]O owner.ConcurrencyControlNumber = item.ConcurrencyControlNumber; owner.CglCompany = item.CglCompany; - owner.CglendDate = item.CglendDate; + if (item.CglendDate is DateTime cglEndDateUtc) + { + owner.CglendDate = DateUtils.AsUTC(cglEndDateUtc); + } owner.CglPolicyNumber = item.CglPolicyNumber; owner.LocalAreaId = item.LocalArea.LocalAreaId; - owner.WorkSafeBcexpiryDate = item.WorkSafeBcexpiryDate; + if (item.WorkSafeBcexpiryDate is DateTime workSafeBcExpiryDateUtc) + { + owner.WorkSafeBcexpiryDate = DateUtils.AsUTC(workSafeBcExpiryDateUtc); + } owner.WorkSafeBcpolicyNumber = item.WorkSafeBcpolicyNumber; owner.IsMaintenanceContractor = item.IsMaintenanceContractor; owner.OrganizationName = item.OrganizationName; @@ -468,21 +474,23 @@ public virtual ActionResult OwnersIdStatusPut([FromRoute]int id, [From public virtual ActionResult OwnersPost([FromBody]OwnerDto item) { // not found - if (item == null) return new NotFoundObjectResult(new HetsResponse("HETS-01", ErrorViewModel.GetDescription("HETS-01", _configuration))); + if (item == null) + return new NotFoundObjectResult( + new HetsResponse("HETS-01", ErrorViewModel.GetDescription("HETS-01", _configuration))); // get status id int? statusId = StatusHelper.GetStatusId(item.Status, "ownerStatus", _context); - if (statusId == null) return new BadRequestObjectResult(new HetsResponse("HETS-23", ErrorViewModel.GetDescription("HETS-23", _configuration))); + if (statusId == null) + return new BadRequestObjectResult( + new HetsResponse("HETS-23", ErrorViewModel.GetDescription("HETS-23", _configuration))); // create record - HetOwner owner = new HetOwner + HetOwner owner = new() { OwnerStatusTypeId = (int)statusId, CglCompany = item.CglCompany, - CglendDate = item.CglendDate, CglPolicyNumber = item.CglPolicyNumber, LocalAreaId = item.LocalArea.LocalAreaId, - WorkSafeBcexpiryDate = item.WorkSafeBcexpiryDate, WorkSafeBcpolicyNumber = item.WorkSafeBcpolicyNumber, IsMaintenanceContractor = item.IsMaintenanceContractor ?? false, OrganizationName = item.OrganizationName, @@ -499,6 +507,16 @@ public virtual ActionResult OwnersPost([FromBody]OwnerDto item) MeetsResidency = item.MeetsResidency }; + if (item.CglendDate is DateTime cglEndDateUtc) + { + owner.CglendDate = DateUtils.AsUTC(cglEndDateUtc); + } + + if (item.WorkSafeBcexpiryDate is DateTime workSafeBcExpiryDateUtc) + { + owner.WorkSafeBcexpiryDate = DateUtils.AsUTC(workSafeBcExpiryDateUtc); + } + if (!string.IsNullOrEmpty(item.RegisteredCompanyNumber)) { owner.RegisteredCompanyNumber = item.RegisteredCompanyNumber; @@ -1172,7 +1190,6 @@ public virtual ActionResult> OwnersIdEquipmentTransferPost( Make = equipmentToTransfer.Make, Model = equipmentToTransfer.Model, Operator = equipmentToTransfer.Operator, - ReceivedDate = equipmentToTransfer.ReceivedDate, LicencePlate = equipmentToTransfer.LicencePlate, SerialNumber = equipmentToTransfer.SerialNumber, Size = equipmentToTransfer.Size, @@ -1180,7 +1197,7 @@ public virtual ActionResult> OwnersIdEquipmentTransferPost( RefuseRate = equipmentToTransfer.RefuseRate, YearsOfService = 0, Year = equipmentToTransfer.Year, - LastVerifiedDate = equipmentToTransfer.LastVerifiedDate, + LastVerifiedDate = DateUtils.AsUTC(equipmentToTransfer.LastVerifiedDate), IsSeniorityOverridden = false, SeniorityOverrideReason = "", Type = equipmentToTransfer.Type, @@ -1193,6 +1210,11 @@ public virtual ActionResult> OwnersIdEquipmentTransferPost( PupLegalCapacity = equipmentToTransfer.PupLegalCapacity }; + if (equipmentToTransfer.ReceivedDate is DateTime receivedDateUtc) + { + newEquipment.ReceivedDate = DateUtils.AsUTC(receivedDateUtc); + } + newEquipment.HetEquipmentAttachments = GetEquipmentAttachments(newEquipment.HetEquipmentAttachments, equipmentToTransfer); @@ -1311,7 +1333,10 @@ private static HetEquipment IncludeSeniorityWithEquipment( newEquipment.ServiceHoursThreeYearsAgo = equipmentToTransfer.ServiceHoursThreeYearsAgo; newEquipment.YearsOfService = equipmentToTransfer.YearsOfService; newEquipment.Seniority = equipmentToTransfer.Seniority; - newEquipment.ApprovedDate = equipmentToTransfer.ApprovedDate; + if (equipmentToTransfer.ApprovedDate is DateTime approvedDateUtc) + { + newEquipment.ApprovedDate = DateUtils.AsUTC(approvedDateUtc); + } } return newEquipment; } @@ -1323,11 +1348,11 @@ private void UpdateRentalAgreements( // we also need to update all of the associated rental agreements // (for this fiscal year) - fiscalStart = DateUtils.AsUTC(fiscalStart); + DateTime fiscalStartUtc = DateUtils.AsUTC(fiscalStart); IQueryable agreements = _context.HetRentalAgreements .Where(x => x.EquipmentId == equipmentToTransfer.EquipmentId && - x.DatedOn >= fiscalStart); + x.DatedOn >= fiscalStartUtc); foreach (HetRentalAgreement agreement in agreements) { @@ -1366,7 +1391,7 @@ public virtual ActionResult> OwnersIdAttachmentsGet([FromRo if (attachment != null) { attachment.FileSize = attachment.FileContents.Length; - attachment.LastUpdateTimestamp = attachment.AppLastUpdateTimestamp; + attachment.LastUpdateTimestamp = DateUtils.AsUTC(attachment.AppLastUpdateTimestamp); attachment.LastUpdateUserid = attachment.AppLastUpdateUserid; attachment.UserName = UserHelper.GetUserName(attachment.LastUpdateUserid, _context); attachments.Add(attachment); diff --git a/Server/HetsApi/Controllers/ProjectController.cs b/Server/HetsApi/Controllers/ProjectController.cs index 2eb3e9fb2..5da2bbadc 100644 --- a/Server/HetsApi/Controllers/ProjectController.cs +++ b/Server/HetsApi/Controllers/ProjectController.cs @@ -658,7 +658,7 @@ public virtual ActionResult> ProjectsIdTimeRecordsPost([From time.Hours = item.Hours; time.TimePeriod = item.TimePeriod; time.TimePeriodTypeId = (int)timePeriodTypeId; - time.WorkedDate = item.WorkedDate; + time.WorkedDate = DateUtils.AsUTC(item.WorkedDate); } else // add time record { @@ -669,7 +669,7 @@ public virtual ActionResult> ProjectsIdTimeRecordsPost([From Hours = item.Hours, TimePeriod = item.TimePeriod, TimePeriodTypeId = (int)timePeriodTypeId, - WorkedDate = item.WorkedDate + WorkedDate = DateUtils.AsUTC(item.WorkedDate) }; _context.HetTimeRecords.Add(time); @@ -759,7 +759,7 @@ public virtual ActionResult> ProjectsIdAttachmentsGet([From if (attachment != null) { attachment.FileSize = attachment.FileContents.Length; - attachment.LastUpdateTimestamp = attachment.AppLastUpdateTimestamp; + attachment.LastUpdateTimestamp = DateUtils.AsUTC(attachment.AppLastUpdateTimestamp); attachment.LastUpdateUserid = attachment.AppLastUpdateUserid; attachment.UserName = UserHelper.GetUserName(attachment.LastUpdateUserid, _context); attachments.Add(attachment); diff --git a/Server/HetsApi/Controllers/RentalAgreementController.cs b/Server/HetsApi/Controllers/RentalAgreementController.cs index 39b80422e..4cc72f5f5 100644 --- a/Server/HetsApi/Controllers/RentalAgreementController.cs +++ b/Server/HetsApi/Controllers/RentalAgreementController.cs @@ -74,13 +74,16 @@ public virtual ActionResult RentalAgreementsIdPut([FromRoute if (item == null || id != item.RentalAgreementId) { // not found - return new NotFoundObjectResult(new HetsResponse("HETS-01", ErrorViewModel.GetDescription("HETS-01", _configuration))); + return new NotFoundObjectResult( + new HetsResponse("HETS-01", ErrorViewModel.GetDescription("HETS-01", _configuration))); } bool exists = _context.HetRentalAgreements.Any(a => a.RentalAgreementId == id); // not found - if (!exists) return new NotFoundObjectResult(new HetsResponse("HETS-01", ErrorViewModel.GetDescription("HETS-01", _configuration))); + if (!exists) + return new NotFoundObjectResult( + new HetsResponse("HETS-01", ErrorViewModel.GetDescription("HETS-01", _configuration))); // get record HetRentalAgreement agreement = _context.HetRentalAgreements @@ -88,7 +91,9 @@ public virtual ActionResult RentalAgreementsIdPut([FromRoute .First(a => a.RentalAgreementId == id); int? statusId = StatusHelper.GetStatusId(item.Status, "rentalAgreementStatus", _context); - if (statusId == null) return new BadRequestObjectResult(new HetsResponse("HETS-23", ErrorViewModel.GetDescription("HETS-23", _configuration))); + if (statusId == null) + return new BadRequestObjectResult( + new HetsResponse("HETS-23", ErrorViewModel.GetDescription("HETS-23", _configuration))); // get overtime records List overtime = _context.HetProvincialRateTypes.AsNoTracking() @@ -96,12 +101,8 @@ public virtual ActionResult RentalAgreementsIdPut([FromRoute .ToList(); // get rate period type for the agreement - int? rateTypeId = StatusHelper.GetRatePeriodId(item.RatePeriod, _context); - - if (rateTypeId == null) - { - throw new DataException("Rate Period Id cannot be null"); - } + int? rateTypeId = StatusHelper.GetRatePeriodId(item.RatePeriod, _context) + ?? throw new DataException("Rate Period Id cannot be null"); string city = item.AgreementCity; @@ -112,7 +113,9 @@ public virtual ActionResult RentalAgreementsIdPut([FromRoute // update the agreement record agreement.ConcurrencyControlNumber = item.ConcurrencyControlNumber; - agreement.DatedOn = item.DatedOn; + if (item.DatedOn is DateTime datedOnUtc) { + agreement.DatedOn = DateUtils.AsUTC(datedOnUtc); + } agreement.AgreementCity = city; agreement.EquipmentRate = item.EquipmentRate; agreement.EstimateHours = item.EstimateHours; @@ -204,15 +207,13 @@ public virtual ActionResult RentalAgreementsIdPut([FromRoute public virtual ActionResult RentalAgreementsPost([FromBody] RentalAgreementDto item) { // not found - if (item == null) return new BadRequestObjectResult(new HetsResponse("HETS-04", ErrorViewModel.GetDescription("HETS-04", _configuration))); + if (item == null) + return new BadRequestObjectResult( + new HetsResponse("HETS-04", ErrorViewModel.GetDescription("HETS-04", _configuration))); // set the rate period type id - int? rateTypeId = StatusHelper.GetRatePeriodId(item.RatePeriod, _context); - - if (rateTypeId == null) - { - throw new DataException("Rate Period Id cannot be null"); - } + int? rateTypeId = StatusHelper.GetRatePeriodId(item.RatePeriod, _context) + ?? throw new DataException("Rate Period Id cannot be null"); // get overtime records List overtime = _context.HetProvincialRateTypes.AsNoTracking() @@ -221,17 +222,18 @@ public virtual ActionResult RentalAgreementsPost([FromBody] // get status for new agreement int? statusId = StatusHelper.GetStatusId(item.Status, "rentalAgreementStatus", _context); - if (statusId == null) return new BadRequestObjectResult(new HetsResponse("HETS-23", ErrorViewModel.GetDescription("HETS-23", _configuration))); + if (statusId == null) + return new BadRequestObjectResult( + new HetsResponse("HETS-23", ErrorViewModel.GetDescription("HETS-23", _configuration))); // get user info - agreement city CurrentUserDto user = UserAccountHelper.GetUser(_context, _httpContext); string agreementCity = user.AgreementCity; // create agreement - HetRentalAgreement agreement = new HetRentalAgreement + HetRentalAgreement agreement = new() { Number = RentalAgreementHelper.GetRentalAgreementNumber(item.Equipment?.LocalAreaId, _context), - DatedOn = item.DatedOn, AgreementCity = agreementCity, EquipmentRate = item.EquipmentRate, EstimateHours = item.EstimateHours, @@ -244,6 +246,11 @@ public virtual ActionResult RentalAgreementsPost([FromBody] ProjectId = item.ProjectId }; + if (item.DatedOn is DateTime datedOnUtc) + { + agreement.DatedOn = DateUtils.AsUTC(datedOnUtc); + } + // agreement overtime records (default overtime flag) if (item.OvertimeRates != null) { @@ -473,7 +480,7 @@ public virtual ActionResult RentalAgreementsIdTimeRecordsPost( time.Hours = item.Hours; time.TimePeriod = item.TimePeriod; time.TimePeriodTypeId = (int)timePeriodTypeId; - time.WorkedDate = item.WorkedDate; + time.WorkedDate = DateUtils.AsUTC(item.WorkedDate); } else // add time record { @@ -484,7 +491,7 @@ public virtual ActionResult RentalAgreementsIdTimeRecordsPost( Hours = item.Hours, TimePeriod = item.TimePeriod, TimePeriodTypeId = (int)timePeriodTypeId, - WorkedDate = item.WorkedDate + WorkedDate = DateUtils.AsUTC(item.WorkedDate) }; _context.HetTimeRecords.Add(time); @@ -543,7 +550,7 @@ public virtual ActionResult RentalAgreementsIdTimeRecordsBulkPos time.Hours = item.Hours; time.TimePeriod = item.TimePeriod; time.TimePeriodTypeId = (int)timePeriodTypeId; - time.WorkedDate = item.WorkedDate; + time.WorkedDate = DateUtils.AsUTC(item.WorkedDate); } else // add time record { @@ -554,7 +561,7 @@ public virtual ActionResult RentalAgreementsIdTimeRecordsBulkPos Hours = item.Hours, TimePeriod = item.TimePeriod, TimePeriodTypeId = (int)timePeriodTypeId, - WorkedDate = item.WorkedDate + WorkedDate = DateUtils.AsUTC(item.WorkedDate) }; _context.HetTimeRecords.Add(time); @@ -1094,10 +1101,14 @@ public virtual ActionResult DeleteBlankRentalAgreementPost([ [HttpPost] [Route("updateCloneBlankAgreement/{id}")] [RequiresPermission(HetPermission.Login, HetPermission.WriteAccess)] - public virtual ActionResult CloneBlankRentalAgreementPost([FromRoute] int id, [FromBody] RentalAgreementDto agreement) + public virtual ActionResult CloneBlankRentalAgreementPost( + [FromRoute] int id, + [FromBody] RentalAgreementDto agreement) { // check the ids - if (id != agreement.RentalAgreementId) return new NotFoundObjectResult(new HetsResponse("HETS-01", ErrorViewModel.GetDescription("HETS-01", _configuration))); + if (id != agreement.RentalAgreementId) + return new NotFoundObjectResult( + new HetsResponse("HETS-01", ErrorViewModel.GetDescription("HETS-01", _configuration))); // get current users district int? districtId = UserAccountHelper.GetUsersDistrictId(_context); @@ -1105,12 +1116,16 @@ public virtual ActionResult CloneBlankRentalAgreementPost([F HetDistrict district = _context.HetDistricts.AsNoTracking() .FirstOrDefault(x => x.DistrictId.Equals(districtId)); - if (district == null) return new NotFoundObjectResult(new HetsResponse("HETS-01", ErrorViewModel.GetDescription("HETS-01", _configuration))); + if (district == null) + return new NotFoundObjectResult( + new HetsResponse("HETS-01", ErrorViewModel.GetDescription("HETS-01", _configuration))); // validate agreement id bool exists = _context.HetRentalAgreements.Any(a => a.RentalAgreementId == id); - if (!exists) return new NotFoundObjectResult(new HetsResponse("HETS-01", ErrorViewModel.GetDescription("HETS-01", _configuration))); + if (!exists) + return new NotFoundObjectResult( + new HetsResponse("HETS-01", ErrorViewModel.GetDescription("HETS-01", _configuration))); // add overtime rates List overtime = _context.HetProvincialRateTypes.AsNoTracking() @@ -1124,7 +1139,7 @@ public virtual ActionResult CloneBlankRentalAgreementPost([F .First(a => a.RentalAgreementId == id); // create new blank agreement as a duplicate - HetRentalAgreement newAgreement = new HetRentalAgreement + HetRentalAgreement newAgreement = new() { Number = RentalAgreementHelper.GetRentalAgreementNumber(district, _context), DistrictId = districtId, @@ -1135,13 +1150,17 @@ public virtual ActionResult CloneBlankRentalAgreementPost([F RateComment = oldAgreement.RateComment?.Trim(), EquipmentRate = oldAgreement.EquipmentRate, Note = oldAgreement.Note?.Trim(), - DatedOn = oldAgreement.DatedOn, AgreementCity = oldAgreement.AgreementCity }; + if (oldAgreement.DatedOn is DateTime datedOnUtc) + { + newAgreement.DatedOn = DateUtils.AsUTC(datedOnUtc); + } + foreach (HetRentalAgreementCondition condition in oldAgreement.HetRentalAgreementConditions) { - HetRentalAgreementCondition newCondition = new HetRentalAgreementCondition + HetRentalAgreementCondition newCondition = new() { RentalAgreementId = id, Comment = condition.Comment, @@ -1155,7 +1174,7 @@ public virtual ActionResult CloneBlankRentalAgreementPost([F { foreach (HetRentalAgreementRate rate in oldAgreement.HetRentalAgreementRates) { - HetRentalAgreementRate newRate = new HetRentalAgreementRate + HetRentalAgreementRate newRate = new() { RentalAgreementId = id, Comment = rate.Comment, diff --git a/Server/HetsApi/Controllers/RentalRequestController.cs b/Server/HetsApi/Controllers/RentalRequestController.cs index 2a4739dc0..41c6ca4a0 100644 --- a/Server/HetsApi/Controllers/RentalRequestController.cs +++ b/Server/HetsApi/Controllers/RentalRequestController.cs @@ -97,18 +97,23 @@ public virtual ActionResult> NoProjectsGet() [HttpPut] [Route("{id}")] [RequiresPermission(HetPermission.Login, HetPermission.WriteAccess)] - public virtual ActionResult RentalRequestsIdPut([FromRoute]int id, [FromBody]RentalRequestDto item) + public virtual ActionResult RentalRequestsIdPut( + [FromRoute]int id, + [FromBody]RentalRequestDto item) { if (item == null || id != item.RentalRequestId) { // not found - return new NotFoundObjectResult(new HetsResponse("HETS-01", ErrorViewModel.GetDescription("HETS-01", _configuration))); + return new NotFoundObjectResult( + new HetsResponse("HETS-01", ErrorViewModel.GetDescription("HETS-01", _configuration))); } bool exists = _context.HetRentalRequests.Any(a => a.RentalRequestId == id); // not found - if (!exists) return new NotFoundObjectResult(new HetsResponse("HETS-01", ErrorViewModel.GetDescription("HETS-01", _configuration))); + if (!exists) + return new NotFoundObjectResult( + new HetsResponse("HETS-01", ErrorViewModel.GetDescription("HETS-01", _configuration))); // get record HetRentalRequest rentalRequest = _context.HetRentalRequests @@ -144,40 +149,48 @@ public virtual ActionResult RentalRequestsIdPut([FromRoute]int hiredCount > item.EquipmentCount) { //"HETS-07": "Rental Request count cannot be less than equipment already hired" - return new BadRequestObjectResult(new HetsResponse("HETS-07", ErrorViewModel.GetDescription("HETS-07", _configuration))); + return new BadRequestObjectResult( + new HetsResponse("HETS-07", ErrorViewModel.GetDescription("HETS-07", _configuration))); } // if the number of hired records is now "over the count" - then close if (hiredCount >= item.EquipmentCount) { int? statusIdComplete = StatusHelper.GetStatusId(HetRentalRequest.StatusComplete, "rentalRequestStatus", _context); - if (statusIdComplete == null) return new BadRequestObjectResult(new HetsResponse("HETS-23", ErrorViewModel.GetDescription("HETS-23", _configuration))); + if (statusIdComplete == null) + return new BadRequestObjectResult( + new HetsResponse("HETS-23", ErrorViewModel.GetDescription("HETS-23", _configuration))); item.RentalRequestStatusTypeId = (int)statusIdComplete; item.Status = "Complete"; } int? statusId = StatusHelper.GetStatusId(item.Status, "rentalRequestStatus", _context); - if (statusId == null) return new BadRequestObjectResult(new HetsResponse("HETS-23", ErrorViewModel.GetDescription("HETS-23", _configuration))); + if (statusId == null) + return new BadRequestObjectResult( + new HetsResponse("HETS-23", ErrorViewModel.GetDescription("HETS-23", _configuration))); // update rental request rentalRequest.ConcurrencyControlNumber = item.ConcurrencyControlNumber; rentalRequest.RentalRequestStatusTypeId = (int)statusId; rentalRequest.EquipmentCount = item.EquipmentCount; - rentalRequest.ExpectedEndDate = item.ExpectedEndDate; - rentalRequest.ExpectedStartDate = item.ExpectedStartDate; + if (item.ExpectedEndDate is DateTime expectedEndDateUtc) + { + rentalRequest.ExpectedEndDate = DateUtils.AsUTC(expectedEndDateUtc); + } + if (item.ExpectedStartDate is DateTime expectedStartDateUtc) + { + rentalRequest.ExpectedStartDate = DateUtils.AsUTC(expectedStartDateUtc); + } rentalRequest.ExpectedHours = item.ExpectedHours; // do we have any attachments (only a single string is ever stored) if (item.RentalRequestAttachments != null && item.RentalRequestAttachments.Count > 0) { - if (rentalRequest.HetRentalRequestAttachments == null) - { - rentalRequest.HetRentalRequestAttachments = new List(); - } + rentalRequest.HetRentalRequestAttachments ??= new List(); - HetRentalRequestAttachment attachment = new HetRentalRequestAttachment + HetRentalRequestAttachment attachment = new() { Attachment = item.RentalRequestAttachments[0].Attachment }; @@ -226,7 +239,9 @@ public virtual ActionResult RentalRequestsViewOnlyPost([FromBo private ActionResult CreateRentalRequest(RentalRequestDto item, bool noProject = false) { // not found - if (item == null) return new BadRequestObjectResult(new HetsResponse("HETS-04", ErrorViewModel.GetDescription("HETS-04", _configuration))); + if (item == null) + return new BadRequestObjectResult( + new HetsResponse("HETS-04", ErrorViewModel.GetDescription("HETS-04", _configuration))); // check if we have an existing rental request for the same // local area and equipment type - if so - throw an error @@ -236,12 +251,14 @@ private ActionResult CreateRentalRequest(RentalRequestDto item // // Note: leaving the "New" code in place in case this changes in the future int? statusIdInProgress = StatusHelper.GetStatusId(HetRentalRequest.StatusInProgress, "rentalRequestStatus", _context); - if (statusIdInProgress == null) return new NotFoundObjectResult(new HetsResponse("HETS-23", ErrorViewModel.GetDescription("HETS-23", _configuration))); + if (statusIdInProgress == null) + return new NotFoundObjectResult( + new HetsResponse("HETS-23", ErrorViewModel.GetDescription("HETS-23", _configuration))); List requests = _context.HetRentalRequests - .Where(x => x.DistrictEquipmentTypeId == item.DistrictEquipmentType.DistrictEquipmentTypeId && - x.LocalAreaId == item.LocalArea.LocalAreaId && - x.RentalRequestStatusTypeId == statusIdInProgress) + .Where(x => x.DistrictEquipmentTypeId == item.DistrictEquipmentType.DistrictEquipmentTypeId + && x.LocalAreaId == item.LocalArea.LocalAreaId + && x.RentalRequestStatusTypeId == statusIdInProgress) .ToList(); // in Progress Rental Request already exists @@ -271,17 +288,25 @@ private ActionResult CreateRentalRequest(RentalRequestDto item } // create new rental request - HetRentalRequest rentalRequest = new HetRentalRequest + HetRentalRequest rentalRequest = new() { LocalAreaId = item.LocalArea.LocalAreaId, DistrictEquipmentTypeId = item.DistrictEquipmentType.DistrictEquipmentTypeId, RentalRequestStatusTypeId = (int)statusIdInProgress, EquipmentCount = item.EquipmentCount, - ExpectedEndDate = item.ExpectedEndDate, - ExpectedStartDate = item.ExpectedStartDate, ExpectedHours = item.ExpectedHours }; + if (item.ExpectedEndDate is DateTime expectedEndDateUtc) + { + rentalRequest.ExpectedEndDate = DateUtils.AsUTC(expectedEndDateUtc); + } + + if (item.ExpectedStartDate is DateTime expectedStartDateUtc) + { + rentalRequest.ExpectedStartDate = DateUtils.AsUTC(expectedStartDateUtc); + } + // is this a "project-less" request? - can't be hired from if (!noProject) { @@ -320,7 +345,7 @@ private ActionResult CreateRentalRequest(RentalRequestDto item if (item.RentalRequestAttachments != null && item.RentalRequestAttachments.Count > 0) { - HetRentalRequestAttachment attachment = new HetRentalRequestAttachment + HetRentalRequestAttachment attachment = new() { Attachment = item.RentalRequestAttachments.ElementAt(0).Attachment }; @@ -714,7 +739,9 @@ private NotFoundObjectResult ModifyRentalAgreement( rentalAgreement.RentalAgreementStatusTypeId = (int)statusIdAgreement; rentalAgreement.DatedOn = DateTime.UtcNow; rentalAgreement.EstimateHours = request.ExpectedHours; - rentalAgreement.EstimateStartWork = request.ExpectedStartDate; + if (request.ExpectedStartDate is DateTime expectedStartDateUtc) { + rentalAgreement.EstimateStartWork = DateUtils.AsUTC(expectedStartDateUtc); + } rentalAgreement.RentalRequestId = request.RentalRequestId; rentalAgreement.RentalRequestRotationListId = requestRotationList.RentalRequestRotationListId; @@ -848,7 +875,7 @@ public virtual ActionResult> RentalRequestsIdAttachmentsGet if (attachment != null) { attachment.FileSize = attachment.FileContents.Length; - attachment.LastUpdateTimestamp = attachment.AppLastUpdateTimestamp; + attachment.LastUpdateTimestamp = DateUtils.AsUTC(attachment.AppLastUpdateTimestamp); attachment.LastUpdateUserid = attachment.AppLastUpdateUserid; attachment.UserName = UserHelper.GetUserName(attachment.LastUpdateUserid, _context); attachments.Add(attachment); diff --git a/Server/HetsApi/Controllers/ReportController.cs b/Server/HetsApi/Controllers/ReportController.cs index 77dd95c1e..d2f3f1a7c 100644 --- a/Server/HetsApi/Controllers/ReportController.cs +++ b/Server/HetsApi/Controllers/ReportController.cs @@ -11,6 +11,8 @@ using HetsData.Dtos; using AutoMapper; using Microsoft.Extensions.Logging; +using System; +using HetsCommon; namespace HetsApi.Controllers { @@ -53,8 +55,8 @@ public virtual ActionResult> BatchReportGet() { ReportId = x.ReportId, DistrictId = x.DistrictId, - StartDate = x.StartDate, - EndDate = x.EndDate, + StartDate = x.StartDate is DateTime startDateUtc ? DateUtils.AsUTC(startDateUtc) : null, + EndDate = x.EndDate is DateTime endDateUtc ? DateUtils.AsUTC(endDateUtc) : null, Complete = x.Complete ?? false }).ToList(); diff --git a/Server/HetsApi/Controllers/UserController.cs b/Server/HetsApi/Controllers/UserController.cs index 7e207a869..6b1e2bbea 100644 --- a/Server/HetsApi/Controllers/UserController.cs +++ b/Server/HetsApi/Controllers/UserController.cs @@ -10,6 +10,8 @@ using AutoMapper; using HetsData.Dtos; using HetsData.Repositories; +using HetsCommon; +using System; namespace HetsApi.Controllers { @@ -374,7 +376,9 @@ public virtual ActionResult> UsersIdRolesGet([FromRoute] int i bool exists = _context.HetUsers.Any(x => x.UserId == id); // not found - if (!exists) return new NotFoundObjectResult(new HetsResponse("HETS-01", ErrorViewModel.GetDescription("HETS-01", _configuration))); + if (!exists) + return new NotFoundObjectResult( + new HetsResponse("HETS-01", ErrorViewModel.GetDescription("HETS-01", _configuration))); // get record var user = _userRepo.GetRecord(id); @@ -392,32 +396,42 @@ public virtual ActionResult> UsersIdRolesGet([FromRoute] int i [HttpPost] [Route("{id}/roles")] [RequiresPermission(HetPermission.UserManagement, HetPermission.WriteAccess)] - public virtual ActionResult> UsersIdRolesPost([FromRoute] int id, [FromBody] UserRoleDto item) + public virtual ActionResult> UsersIdRolesPost( + [FromRoute] int id, + [FromBody] UserRoleDto item) { //check for user bool exists = _context.HetUsers.Any(x => x.UserId == id); - if (!exists) return new NotFoundObjectResult(new HetsResponse("HETS-01", ErrorViewModel.GetDescription("HETS-01", _configuration))); + if (!exists) + return new NotFoundObjectResult( + new HetsResponse("HETS-01", ErrorViewModel.GetDescription("HETS-01", _configuration))); // check the role id bool roleExists = _context.HetRoles.Any(x => x.RoleId == item.RoleId); - if (!roleExists) return new NotFoundObjectResult(new HetsResponse("HETS-01", ErrorViewModel.GetDescription("HETS-01", _configuration))); + if (!roleExists) + return new NotFoundObjectResult( + new HetsResponse("HETS-01", ErrorViewModel.GetDescription("HETS-01", _configuration))); // check the user exists and return only active roles var user = _userRepo.GetRecord(id, excludeInactiveRoles: true); - if (user == null) return new NotFoundObjectResult(new HetsResponse("HETS-01", ErrorViewModel.GetDescription("HETS-01", _configuration))); + if (user == null) + return new NotFoundObjectResult( + new HetsResponse("HETS-01", ErrorViewModel.GetDescription("HETS-01", _configuration))); //check if user already has the same role active bool activeRoleExists = user.UserRoles.Any(x => x.RoleId == item.RoleId); - if (activeRoleExists) return new NotFoundObjectResult(new HetsResponse("HETS-45", ErrorViewModel.GetDescription("HETS-45", _configuration))); + if (activeRoleExists) + return new NotFoundObjectResult( + new HetsResponse("HETS-45", ErrorViewModel.GetDescription("HETS-45", _configuration))); // create a new UserRole record - HetUserRole userRole = new HetUserRole + HetUserRole userRole = new() { RoleId = item.RoleId, UserId = id, - EffectiveDate = item.EffectiveDate, - ExpiryDate = item.ExpiryDate + EffectiveDate = DateUtils.AsUTC(item.EffectiveDate), + ExpiryDate = item.ExpiryDate is DateTime expiryDateUtc ? DateUtils.AsUTC(expiryDateUtc) : null, }; _context.HetUserRoles.Add(userRole); @@ -440,24 +454,32 @@ public virtual ActionResult> UsersIdRolesPost([FromRoute] int [HttpPut] [Route("{id}/roles")] [RequiresPermission(HetPermission.UserManagement, HetPermission.WriteAccess)] - public virtual ActionResult> UsersIdRolesPut([FromRoute] int id, [FromBody] UserRoleDto[] items) + public virtual ActionResult> UsersIdRolesPut( + [FromRoute] int id, + [FromBody] UserRoleDto[] items) { //confirm user exists bool userExists = _context.HetUsers.Any(x => x.UserId == id); - if (!userExists || items == null) return new NotFoundObjectResult(new HetsResponse("HETS-01", ErrorViewModel.GetDescription("HETS-01", _configuration))); + if (!userExists || items == null) + return new NotFoundObjectResult( + new HetsResponse("HETS-01", ErrorViewModel.GetDescription("HETS-01", _configuration))); //confirm all items belong to the user, using UserRoleId //confirm all items exist in database foreach (var item in items) { var result = _context.HetUserRoles.FirstOrDefault(x => x.UserRoleId == item.UserRoleId && x.UserId == id); - if (result == null) return new NotFoundObjectResult(new HetsResponse("HETS-44", ErrorViewModel.GetDescription("HETS-44", _configuration))); + if (result == null) + return new NotFoundObjectResult( + new HetsResponse("HETS-44", ErrorViewModel.GetDescription("HETS-44", _configuration))); } // get record var user = _userRepo.GetRecord(id); - if (user.UserRoles == null) return new NotFoundObjectResult(new HetsResponse("HETS-01", ErrorViewModel.GetDescription("HETS-01", _configuration))); + if (user.UserRoles == null) + return new NotFoundObjectResult( + new HetsResponse("HETS-01", ErrorViewModel.GetDescription("HETS-01", _configuration))); // iterate the roles and update effective date foreach (var item in items) @@ -466,7 +488,9 @@ public virtual ActionResult> UsersIdRolesPut([FromRoute] int i if (role.ExpiryDate != item.ExpiryDate) { - role.ExpiryDate = item.ExpiryDate; + role.ExpiryDate = + item.ExpiryDate is DateTime expiryDateUtc ? + DateUtils.AsUTC(expiryDateUtc) : null; } } _context.SaveChanges(); diff --git a/Server/HetsApi/Model/AitReport.cs b/Server/HetsApi/Model/AitReport.cs index 897684181..52e9cbf90 100644 --- a/Server/HetsApi/Model/AitReport.cs +++ b/Server/HetsApi/Model/AitReport.cs @@ -1,9 +1,7 @@ -using HetsData.Entities; +using HetsCommon; +using HetsData.Entities; using Newtonsoft.Json; using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; namespace HetsApi.Model { @@ -50,8 +48,11 @@ public static AitReport MapFromHetRentalAgreement(HetRentalAgreement agreement) ProjectNumber = agreement.Project?.ProvincialProjectNumber, ProjectName = agreement.Project?.Name, - DatedOn = agreement.DatedOn, - StartDate = agreement.EstimateStartWork, + DatedOn = agreement.DatedOn is DateTime datedOnUtc ? + DateUtils.AsUTC(datedOnUtc) : null, + + StartDate = agreement.EstimateStartWork is DateTime estimateStartWorkUtc ? + DateUtils.AsUTC(estimateStartWorkUtc) : null, }; return report; diff --git a/Server/HetsData/Entities/DbAppContextExtension.cs b/Server/HetsData/Entities/DbAppContextExtension.cs index e5c37625b..65f1d9dae 100644 --- a/Server/HetsData/Entities/DbAppContextExtension.cs +++ b/Server/HetsData/Entities/DbAppContextExtension.cs @@ -3,6 +3,7 @@ using System.Diagnostics; using System.Linq; using System.Reflection; +using HetsCommon; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.ChangeTracking; using Microsoft.Extensions.Logging; @@ -252,9 +253,9 @@ private void DoEquipmentAudit(List audits, EntityEntry entry, seniorityAudit.OwnerOrganizationName = seniorityAudit.Owner.OrganizationName; } - if (original.SeniorityEffectiveDate != null) + if (original.SeniorityEffectiveDate is DateTime seniorityEffectiveDateUtc) { - seniorityAudit.StartDate = (DateTime)original.SeniorityEffectiveDate; + seniorityAudit.StartDate = DateUtils.AsUTC(seniorityEffectiveDateUtc); } seniorityAudit.Seniority = original.Seniority; diff --git a/Server/HetsData/Helpers/EquipmentHelper.cs b/Server/HetsData/Helpers/EquipmentHelper.cs index f166a2abc..139635ab0 100644 --- a/Server/HetsData/Helpers/EquipmentHelper.cs +++ b/Server/HetsData/Helpers/EquipmentHelper.cs @@ -223,7 +223,7 @@ public static EquipmentLiteDto ToLiteModel(HetEquipment equipment, SeniorityScor 0; equipmentLite.AttachmentCount = CalculateAttachmentCount(equipment.HetEquipmentAttachments.ToList()); - equipmentLite.LastVerifiedDate = equipment.LastVerifiedDate; + equipmentLite.LastVerifiedDate = DateUtils.AsUTC(equipment.LastVerifiedDate); equipmentLite.Status = equipment.EquipmentStatusType.EquipmentStatusTypeCode; equipmentLite.LocalArea = equipment.LocalArea.Name; @@ -625,7 +625,7 @@ public static List GetHistoryRecords(int id, int? offset, int? limit, D { temp.HistoryText = data[i].HistoryText; temp.Id = data[i].HistoryId; - temp.LastUpdateTimestamp = data[i].AppLastUpdateTimestamp; + temp.LastUpdateTimestamp = DateUtils.AsUTC(data[i].AppLastUpdateTimestamp); temp.LastUpdateUserid = data[i].AppLastUpdateUserid; temp.AffectedEntityId = data[i].EquipmentId; } diff --git a/Server/HetsData/Helpers/OwnerHelper.cs b/Server/HetsData/Helpers/OwnerHelper.cs index c42d387e5..3fff290ca 100644 --- a/Server/HetsData/Helpers/OwnerHelper.cs +++ b/Server/HetsData/Helpers/OwnerHelper.cs @@ -6,6 +6,7 @@ using Microsoft.Extensions.Configuration; using HetsData.Entities; using HetsData.Dtos; +using HetsCommon; namespace HetsData.Helpers { @@ -192,9 +193,13 @@ public static OwnerWcbCgl ToWcbCglModel(HetOwner owner) } ownerLite.WcbNumber = owner.WorkSafeBcpolicyNumber; - ownerLite.WcbExpiryDate = owner.WorkSafeBcexpiryDate; + ownerLite.WcbExpiryDate = + owner.WorkSafeBcexpiryDate is DateTime wcbExpiryDateUtc ? + DateUtils.AsUTC(wcbExpiryDateUtc) : null; ownerLite.CglNumber = owner.CglPolicyNumber; - ownerLite.CglExpiryDate = owner.CglendDate; + ownerLite.CglExpiryDate = + owner.CglendDate is DateTime cglEndDateUtc ? + DateUtils.AsUTC(cglEndDateUtc) : null; } return ownerLite; diff --git a/Server/HetsData/Helpers/ProjectHelper.cs b/Server/HetsData/Helpers/ProjectHelper.cs index c58add590..d9a6ade55 100644 --- a/Server/HetsData/Helpers/ProjectHelper.cs +++ b/Server/HetsData/Helpers/ProjectHelper.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; +using HetsCommon; using HetsData.Dtos; using HetsData.Entities; using Microsoft.EntityFrameworkCore; @@ -78,7 +79,7 @@ public static List GetHistoryRecords(int id, int? offset, int? limit, D { temp.HistoryText = data[i].HistoryText; temp.Id = data[i].HistoryId; - temp.LastUpdateTimestamp = data[i].AppLastUpdateTimestamp; + temp.LastUpdateTimestamp = DateUtils.AsUTC(data[i].AppLastUpdateTimestamp); temp.LastUpdateUserid = data[i].AppLastUpdateUserid; temp.AffectedEntityId = data[i].ProjectId; } diff --git a/Server/HetsData/Helpers/RentalAgreementHelper.cs b/Server/HetsData/Helpers/RentalAgreementHelper.cs index e1f9773d8..e895f43ca 100644 --- a/Server/HetsData/Helpers/RentalAgreementHelper.cs +++ b/Server/HetsData/Helpers/RentalAgreementHelper.cs @@ -62,12 +62,13 @@ public static class RentalAgreementHelper /// public static RentalAgreementSummaryLite ToSummaryLiteModel(HetRentalAgreement agreement) { - RentalAgreementSummaryLite agreementSummary = new RentalAgreementSummaryLite(); + RentalAgreementSummaryLite agreementSummary = new(); if (agreement != null) { agreementSummary.Id = agreement.RentalAgreementId; - agreementSummary.DatedOn = agreement.DatedOn; + agreementSummary.DatedOn = + agreement.DatedOn is DateTime datedOnUtc ? DateUtils.AsUTC(datedOnUtc) : null; } return agreementSummary; diff --git a/Server/HetsData/Helpers/RentalRequestHelper.cs b/Server/HetsData/Helpers/RentalRequestHelper.cs index 72c57bc99..b0f63005b 100644 --- a/Server/HetsData/Helpers/RentalRequestHelper.cs +++ b/Server/HetsData/Helpers/RentalRequestHelper.cs @@ -96,7 +96,8 @@ public static RentalRequestHires ToHiresModel(HetRentalRequestRotationList reque // project data requestLite.ProjectId = request.RentalRequest.Project.ProjectId; requestLite.ProjectNumber = request.RentalRequest.Project.ProvincialProjectNumber; - requestLite.NoteDate = request.OfferResponseDatetime; + requestLite.NoteDate = request.OfferResponseDatetime is DateTime offerResponseDtUtc + ? DateUtils.AsUTC(offerResponseDtUtc) : null; // Note Type - // * Not hired (for recording the response NO for hiring. @@ -323,12 +324,13 @@ private static HetEquipment LastAskedByBlockInSeniorityList( if (districtEquipmentTypeId == null || localAreaId == null) return null; // if this is not block 1 - check that we have "asked" anyone in the previous list + DateTime fiscalStartUtc = DateUtils.AsUTC(fiscalStart); var rotationListquery = context.HetRentalRequestRotationLists.AsNoTracking() .Include(x => x.RentalRequest) .Include(x => x.Equipment) .Where(x => x.RentalRequest.DistrictEquipmentTypeId == districtEquipmentTypeId && x.RentalRequest.LocalAreaId == localAreaId && - x.RentalRequest.AppCreateTimestamp >= fiscalStart && + x.RentalRequest.AppCreateTimestamp >= fiscalStartUtc && x.BlockNumber == blockNumber && //use historical block number of the equipment x.WasAsked == true && x.IsForceHire != true) @@ -687,7 +689,7 @@ public static List GetHistoryRecords(int id, int? offset, int? limit, D { temp.HistoryText = data[i].HistoryText; temp.Id = data[i].HistoryId; - temp.LastUpdateTimestamp = data[i].AppLastUpdateTimestamp; + temp.LastUpdateTimestamp = DateUtils.AsUTC(data[i].AppLastUpdateTimestamp); temp.LastUpdateUserid = data[i].AppLastUpdateUserid; temp.AffectedEntityId = data[i].RentalRequestId; } diff --git a/Server/HetsData/Helpers/TimeRecordHelper.cs b/Server/HetsData/Helpers/TimeRecordHelper.cs index 17db576dd..0ec3d0d24 100644 --- a/Server/HetsData/Helpers/TimeRecordHelper.cs +++ b/Server/HetsData/Helpers/TimeRecordHelper.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Text.RegularExpressions; +using HetsCommon; using HetsData.Dtos; using HetsData.Entities; @@ -55,14 +56,15 @@ public static class TimeRecordHelper /// public static TimeRecordSearchLite ToLiteModel(HetTimeRecord timeRecord) { - TimeRecordSearchLite timeLite = new TimeRecordSearchLite(); + TimeRecordSearchLite timeLite = new(); if (timeRecord != null) { timeLite.Id = timeRecord.TimeRecordId; timeLite.Hours = timeRecord.Hours; - timeLite.WorkedDate = timeRecord.WorkedDate; - timeLite.EnteredDate = timeRecord.EnteredDate; + timeLite.WorkedDate = DateUtils.AsUTC(timeRecord.WorkedDate); + timeLite.EnteredDate = timeRecord.EnteredDate is DateTime enteredDateUtc ? + DateUtils.AsUTC(enteredDateUtc) : null; timeLite.RentalAgreementId = timeRecord.RentalAgreement.RentalAgreementId; timeLite.LocalAreaId = timeRecord.RentalAgreement.Equipment.LocalArea.LocalAreaId; timeLite.LocalAreaName = timeRecord.RentalAgreement.Equipment.LocalArea.Name; diff --git a/Server/HetsData/Repositories/OwnerRepository.cs b/Server/HetsData/Repositories/OwnerRepository.cs index 6f0d395c1..d7f185be4 100644 --- a/Server/HetsData/Repositories/OwnerRepository.cs +++ b/Server/HetsData/Repositories/OwnerRepository.cs @@ -11,6 +11,7 @@ using System.Text.RegularExpressions; using System.Threading.Tasks; using Microsoft.Extensions.Logging; +using HetsCommon; namespace HetsData.Repositories { @@ -145,7 +146,7 @@ public List GetHistoryRecords(int id, int? offset, int? limit) { temp.HistoryText = data[i].HistoryText; temp.Id = data[i].HistoryId; - temp.LastUpdateTimestamp = data[i].AppLastUpdateTimestamp; + temp.LastUpdateTimestamp = DateUtils.AsUTC(data[i].AppLastUpdateTimestamp); temp.LastUpdateUserid = data[i].AppLastUpdateUserid; temp.AffectedEntityId = data[i].OwnerId; } diff --git a/Server/HetsData/Repositories/RentalRequestRepository.cs b/Server/HetsData/Repositories/RentalRequestRepository.cs index 3a28069d4..95fe44f60 100644 --- a/Server/HetsData/Repositories/RentalRequestRepository.cs +++ b/Server/HetsData/Repositories/RentalRequestRepository.cs @@ -6,6 +6,7 @@ using Microsoft.Extensions.Configuration; using System; using System.Linq; +using HetsCommon; namespace HetsData.Repositories { @@ -64,8 +65,13 @@ public RentalRequestLite ToLiteModel(HetRentalRequest request) requestLite.Status = request.RentalRequestStatusType.Description; requestLite.EquipmentCount = request.EquipmentCount; - requestLite.ExpectedEndDate = request.ExpectedEndDate; - requestLite.ExpectedStartDate = request.ExpectedStartDate; + requestLite.ExpectedEndDate = + request.ExpectedEndDate is DateTime expectedEndDateUtc ? + DateUtils.AsUTC(expectedEndDateUtc) : null; + + requestLite.ExpectedStartDate = + request.ExpectedStartDate is DateTime expectedStartDateUtc ? + DateUtils.AsUTC(expectedStartDateUtc) : null; } return requestLite; @@ -119,7 +125,7 @@ public RentalRequestDto GetRecordWithRotationList(int id, SeniorityScoringRules .FirstOrDefault(a => a.RentalRequestId == id); //pull out the date that request was last updated - var requestDate = request.AppLastUpdateTimestamp; + var requestDate = DateUtils.AsUTC(request.AppLastUpdateTimestamp); foreach (var rrrl in request.HetRentalRequestRotationLists) {