mirror of
https://github.com/Sea-Haven-Industries/shoc-backend.git
synced 2026-09-30 08:23:12 +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,
|
StartDate = startDate,
|
||||||
EndDate = startDate,
|
EndDate = startDate,
|
||||||
IsDeleted = isDeleted,
|
IsDeleted = isDeleted,
|
||||||
CreatedDate = DateTime.Now
|
CreatedDate = DateTime.UtcNow
|
||||||
};
|
};
|
||||||
ctx.Events.Add(ev);
|
ctx.Events.Add(ev);
|
||||||
ctx.SaveChanges();
|
ctx.SaveChanges();
|
||||||
|
|
@ -64,6 +64,7 @@ public class CalendarServiceTests
|
||||||
saved.Title.Should().Be("Standup");
|
saved.Title.Should().Be("Standup");
|
||||||
saved.IsDeleted.Should().Be(false);
|
saved.IsDeleted.Should().Be(false);
|
||||||
saved.CreatedDate.Should().NotBeNull();
|
saved.CreatedDate.Should().NotBeNull();
|
||||||
|
saved.CreatedDate!.Value.Kind.Should().Be(DateTimeKind.Utc);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|
@ -97,6 +98,7 @@ public class CalendarServiceTests
|
||||||
var updated = ctx.Events.Single();
|
var updated = ctx.Events.Single();
|
||||||
updated.Title.Should().Be("New");
|
updated.Title.Should().Be("New");
|
||||||
updated.LastModificationTime.Should().NotBeNull();
|
updated.LastModificationTime.Should().NotBeNull();
|
||||||
|
updated.LastModificationTime!.Value.Kind.Should().Be(DateTimeKind.Utc);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|
@ -134,6 +136,7 @@ public class CalendarServiceTests
|
||||||
var row = ctx.Events.Single();
|
var row = ctx.Events.Single();
|
||||||
row.IsDeleted.Should().Be(true);
|
row.IsDeleted.Should().Be(true);
|
||||||
row.DeletionTime.Should().NotBeNull();
|
row.DeletionTime.Should().NotBeNull();
|
||||||
|
row.DeletionTime!.Value.Kind.Should().Be(DateTimeKind.Utc);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ namespace SeaHaven.Services.Implementation
|
||||||
EndDate = input.EndDate,
|
EndDate = input.EndDate,
|
||||||
EndTime = input.EndTime,
|
EndTime = input.EndTime,
|
||||||
AllDay = input.AllDay,
|
AllDay = input.AllDay,
|
||||||
CreatedDate = DateTime.Now,
|
CreatedDate = DateTime.UtcNow,
|
||||||
IsDeleted = false
|
IsDeleted = false
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -57,7 +57,7 @@ namespace SeaHaven.Services.Implementation
|
||||||
model.EndDate = input.EndDate;
|
model.EndDate = input.EndDate;
|
||||||
model.EndTime = input.EndTime;
|
model.EndTime = input.EndTime;
|
||||||
model.AllDay = input.AllDay;
|
model.AllDay = input.AllDay;
|
||||||
model.LastModificationTime = DateTime.Now;
|
model.LastModificationTime = DateTime.UtcNow;
|
||||||
|
|
||||||
await _dataService.UpdateEventAsync(model, cancellationToken);
|
await _dataService.UpdateEventAsync(model, cancellationToken);
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -76,7 +76,7 @@ namespace SeaHaven.Services.Implementation
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
model.IsDeleted = true;
|
model.IsDeleted = true;
|
||||||
model.DeletionTime = DateTime.Now;
|
model.DeletionTime = DateTime.UtcNow;
|
||||||
|
|
||||||
await _dataService.UpdateEventAsync(model, cancellationToken);
|
await _dataService.UpdateEventAsync(model, cancellationToken);
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
|
|
@ -104,7 +104,7 @@ namespace SeaHaven.Services.Implementation
|
||||||
ContactType = dto.Type,
|
ContactType = dto.Type,
|
||||||
AccountId = dto.AccountId,
|
AccountId = dto.AccountId,
|
||||||
createdby = userId,
|
createdby = userId,
|
||||||
CreatedDate = DateTime.Now
|
CreatedDate = DateTime.UtcNow
|
||||||
};
|
};
|
||||||
|
|
||||||
var savedContact = await _contactDataService.AddAsync(contact);
|
var savedContact = await _contactDataService.AddAsync(contact);
|
||||||
|
|
@ -151,7 +151,7 @@ namespace SeaHaven.Services.Implementation
|
||||||
if (dto.AccountId.HasValue)
|
if (dto.AccountId.HasValue)
|
||||||
existingContact.AccountId = dto.AccountId;
|
existingContact.AccountId = dto.AccountId;
|
||||||
|
|
||||||
existingContact.LastModificationTime = DateTime.Now;
|
existingContact.LastModificationTime = DateTime.UtcNow;
|
||||||
|
|
||||||
await _contactDataService.UpdateAsync(existingContact);
|
await _contactDataService.UpdateAsync(existingContact);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -399,7 +399,7 @@ namespace SeaHaven.Services.Implementation
|
||||||
{
|
{
|
||||||
ThrowOnInvalidContacts(contacts);
|
ThrowOnInvalidContacts(contacts);
|
||||||
|
|
||||||
var now = DateTime.Now;
|
var now = DateTime.UtcNow;
|
||||||
var siteContacts = contacts
|
var siteContacts = contacts
|
||||||
.Select((row, index) => new Contacts
|
.Select((row, index) => new Contacts
|
||||||
{
|
{
|
||||||
|
|
@ -457,7 +457,7 @@ namespace SeaHaven.Services.Implementation
|
||||||
existing.PhoneNumber = phone;
|
existing.PhoneNumber = phone;
|
||||||
existing.SiteContactOrder = i;
|
existing.SiteContactOrder = i;
|
||||||
existing.AccountId = location.AccountId;
|
existing.AccountId = location.AccountId;
|
||||||
existing.LastModificationTime = DateTime.Now;
|
existing.LastModificationTime = DateTime.UtcNow;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -470,7 +470,7 @@ namespace SeaHaven.Services.Implementation
|
||||||
PhoneNumber = phone,
|
PhoneNumber = phone,
|
||||||
SiteContactOrder = i,
|
SiteContactOrder = i,
|
||||||
AccountId = location.AccountId,
|
AccountId = location.AccountId,
|
||||||
CreatedDate = DateTime.Now,
|
CreatedDate = DateTime.UtcNow,
|
||||||
createdby = actorId
|
createdby = actorId
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -478,7 +478,7 @@ namespace SeaHaven.Services.Implementation
|
||||||
|
|
||||||
// Rows omitted from the request are soft deleted so historical
|
// Rows omitted from the request are soft deleted so historical
|
||||||
// WorkOrderContacts keep rendering.
|
// WorkOrderContacts keep rendering.
|
||||||
var now = DateTime.Now;
|
var now = DateTime.UtcNow;
|
||||||
foreach (var existing in existingById.Values)
|
foreach (var existing in existingById.Values)
|
||||||
{
|
{
|
||||||
if (keptIds.Contains(existing.Id) || existing.IsDeleted == true)
|
if (keptIds.Contains(existing.Id) || existing.IsDeleted == true)
|
||||||
|
|
|
||||||
|
|
@ -72,7 +72,7 @@ namespace SeaHaven.Services.Implementation
|
||||||
{
|
{
|
||||||
model.EmailConfirmed = true;
|
model.EmailConfirmed = true;
|
||||||
model.UserName = model.Email;
|
model.UserName = model.Email;
|
||||||
model.CreatedDate = DateTime.Now;
|
model.CreatedDate = DateTime.UtcNow;
|
||||||
model.UniqueName = "Active";
|
model.UniqueName = "Active";
|
||||||
model.PhoneNumber = dto.Role;
|
model.PhoneNumber = dto.Role;
|
||||||
|
|
||||||
|
|
@ -152,7 +152,7 @@ namespace SeaHaven.Services.Implementation
|
||||||
exist.Email = dto.Email;
|
exist.Email = dto.Email;
|
||||||
exist.NormalizedEmail = dto.Email.ToUpperInvariant();
|
exist.NormalizedEmail = dto.Email.ToUpperInvariant();
|
||||||
exist.NormalizedUserName = dto.Email.ToUpperInvariant();
|
exist.NormalizedUserName = dto.Email.ToUpperInvariant();
|
||||||
exist.CreatedDate = DateTime.Now;
|
exist.CreatedDate = DateTime.UtcNow;
|
||||||
exist.UniqueName = "Active";
|
exist.UniqueName = "Active";
|
||||||
exist.PhoneNumber = dto.Role;
|
exist.PhoneNumber = dto.Role;
|
||||||
exist.AccountId = dto.AccountId;
|
exist.AccountId = dto.AccountId;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue