mirror of
https://github.com/Sea-Haven-Industries/shoc-backend.git
synced 2026-09-30 03:43:11 +00:00
fix(services): stamp user, contact, calendar and location audit times in UTC
User creation, contact, calendar event and site-contact create/modify/delete stamps used local server time. Validation rules comparing user-entered dates and the JWT expiry are unchanged.
This commit is contained in:
parent
6bfb56f349
commit
27c21ec32e
5 changed files with 15 additions and 12 deletions
|
|
@ -44,7 +44,7 @@ public class CalendarServiceTests
|
|||
StartDate = startDate,
|
||||
EndDate = startDate,
|
||||
IsDeleted = isDeleted,
|
||||
CreatedDate = DateTime.Now
|
||||
CreatedDate = DateTime.UtcNow
|
||||
};
|
||||
ctx.Events.Add(ev);
|
||||
ctx.SaveChanges();
|
||||
|
|
@ -64,6 +64,7 @@ public class CalendarServiceTests
|
|||
saved.Title.Should().Be("Standup");
|
||||
saved.IsDeleted.Should().Be(false);
|
||||
saved.CreatedDate.Should().NotBeNull();
|
||||
saved.CreatedDate!.Value.Kind.Should().Be(DateTimeKind.Utc);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
@ -97,6 +98,7 @@ public class CalendarServiceTests
|
|||
var updated = ctx.Events.Single();
|
||||
updated.Title.Should().Be("New");
|
||||
updated.LastModificationTime.Should().NotBeNull();
|
||||
updated.LastModificationTime!.Value.Kind.Should().Be(DateTimeKind.Utc);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
@ -134,6 +136,7 @@ public class CalendarServiceTests
|
|||
var row = ctx.Events.Single();
|
||||
row.IsDeleted.Should().Be(true);
|
||||
row.DeletionTime.Should().NotBeNull();
|
||||
row.DeletionTime!.Value.Kind.Should().Be(DateTimeKind.Utc);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ namespace SeaHaven.Services.Implementation
|
|||
EndDate = input.EndDate,
|
||||
EndTime = input.EndTime,
|
||||
AllDay = input.AllDay,
|
||||
CreatedDate = DateTime.Now,
|
||||
CreatedDate = DateTime.UtcNow,
|
||||
IsDeleted = false
|
||||
};
|
||||
|
||||
|
|
@ -57,7 +57,7 @@ namespace SeaHaven.Services.Implementation
|
|||
model.EndDate = input.EndDate;
|
||||
model.EndTime = input.EndTime;
|
||||
model.AllDay = input.AllDay;
|
||||
model.LastModificationTime = DateTime.Now;
|
||||
model.LastModificationTime = DateTime.UtcNow;
|
||||
|
||||
await _dataService.UpdateEventAsync(model, cancellationToken);
|
||||
return true;
|
||||
|
|
@ -76,7 +76,7 @@ namespace SeaHaven.Services.Implementation
|
|||
return false;
|
||||
|
||||
model.IsDeleted = true;
|
||||
model.DeletionTime = DateTime.Now;
|
||||
model.DeletionTime = DateTime.UtcNow;
|
||||
|
||||
await _dataService.UpdateEventAsync(model, cancellationToken);
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -104,7 +104,7 @@ namespace SeaHaven.Services.Implementation
|
|||
ContactType = dto.Type,
|
||||
AccountId = dto.AccountId,
|
||||
createdby = userId,
|
||||
CreatedDate = DateTime.Now
|
||||
CreatedDate = DateTime.UtcNow
|
||||
};
|
||||
|
||||
var savedContact = await _contactDataService.AddAsync(contact);
|
||||
|
|
@ -151,7 +151,7 @@ namespace SeaHaven.Services.Implementation
|
|||
if (dto.AccountId.HasValue)
|
||||
existingContact.AccountId = dto.AccountId;
|
||||
|
||||
existingContact.LastModificationTime = DateTime.Now;
|
||||
existingContact.LastModificationTime = DateTime.UtcNow;
|
||||
|
||||
await _contactDataService.UpdateAsync(existingContact);
|
||||
|
||||
|
|
|
|||
|
|
@ -399,7 +399,7 @@ namespace SeaHaven.Services.Implementation
|
|||
{
|
||||
ThrowOnInvalidContacts(contacts);
|
||||
|
||||
var now = DateTime.Now;
|
||||
var now = DateTime.UtcNow;
|
||||
var siteContacts = contacts
|
||||
.Select((row, index) => new Contacts
|
||||
{
|
||||
|
|
@ -457,7 +457,7 @@ namespace SeaHaven.Services.Implementation
|
|||
existing.PhoneNumber = phone;
|
||||
existing.SiteContactOrder = i;
|
||||
existing.AccountId = location.AccountId;
|
||||
existing.LastModificationTime = DateTime.Now;
|
||||
existing.LastModificationTime = DateTime.UtcNow;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -470,7 +470,7 @@ namespace SeaHaven.Services.Implementation
|
|||
PhoneNumber = phone,
|
||||
SiteContactOrder = i,
|
||||
AccountId = location.AccountId,
|
||||
CreatedDate = DateTime.Now,
|
||||
CreatedDate = DateTime.UtcNow,
|
||||
createdby = actorId
|
||||
});
|
||||
}
|
||||
|
|
@ -478,7 +478,7 @@ namespace SeaHaven.Services.Implementation
|
|||
|
||||
// Rows omitted from the request are soft deleted so historical
|
||||
// WorkOrderContacts keep rendering.
|
||||
var now = DateTime.Now;
|
||||
var now = DateTime.UtcNow;
|
||||
foreach (var existing in existingById.Values)
|
||||
{
|
||||
if (keptIds.Contains(existing.Id) || existing.IsDeleted == true)
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ namespace SeaHaven.Services.Implementation
|
|||
{
|
||||
model.EmailConfirmed = true;
|
||||
model.UserName = model.Email;
|
||||
model.CreatedDate = DateTime.Now;
|
||||
model.CreatedDate = DateTime.UtcNow;
|
||||
model.UniqueName = "Active";
|
||||
model.PhoneNumber = dto.Role;
|
||||
|
||||
|
|
@ -152,7 +152,7 @@ namespace SeaHaven.Services.Implementation
|
|||
exist.Email = dto.Email;
|
||||
exist.NormalizedEmail = dto.Email.ToUpperInvariant();
|
||||
exist.NormalizedUserName = dto.Email.ToUpperInvariant();
|
||||
exist.CreatedDate = DateTime.Now;
|
||||
exist.CreatedDate = DateTime.UtcNow;
|
||||
exist.UniqueName = "Active";
|
||||
exist.PhoneNumber = dto.Role;
|
||||
exist.AccountId = dto.AccountId;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue