Skip to content

Commit 3b50676

Browse files
CFODEV-1370: Use UTC for audit. Clear created by on clone of risk (#759)
Use UTC for audit. Clear created by on clone of risk
1 parent 99d3dec commit 3b50676

3 files changed

Lines changed: 7 additions & 3 deletions

File tree

src/Domain/Entities/AuditTrail.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ private AuditTrail()
1212
{
1313
}
1414

15-
public static AuditTrail Create(string tableName, string? userId, AuditType auditType)
15+
public static AuditTrail Create(string tableName, string? userId, AuditType auditType, DateTime dateTime)
1616
{
1717
return new AuditTrail()
1818
{
1919
TableName = tableName,
2020
UserId = userId,
21-
DateTime = DateTime.Now,
21+
DateTime = dateTime,
2222
AuditType = auditType,
2323
AffectedColumns = new List<string>(),
2424
NewValues = new Dictionary<string, object?>(),

src/Domain/Entities/Participants/Risk.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ public static Risk Review(Risk from, RiskReviewReason reason, string? justificat
5353
from.Completed = null;
5454
from.CompletedBy = null;
5555
from.RegistrationDetailsJson = null;
56+
from.Created = null;
57+
from.CreatedBy = null;
58+
from.LastModified = null;
59+
from.LastModifiedBy = null;
5660
if (reason == RiskReviewReason.NoChange || reason ==RiskReviewReason.NoRiskInformationAvailable)
5761
{
5862
from.AddDomainEvent(new RiskInformationReviewedDomainEvent(from));

src/Infrastructure/Persistence/Interceptors/AuditibleEntityInterceptor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ private List<AuditTrail> TryInsertTemporaryAuditTrail(DbContext context)
118118
_ => throw new ArgumentOutOfRangeException($"No audit setup for {entry.State}")
119119
};
120120

121-
var auditEntry = AuditTrail.Create(entry.Entity.GetType().Name, userId, auditType);
121+
var auditEntry = AuditTrail.Create(entry.Entity.GetType().Name, userId, auditType, dateTime.Now);
122122

123123
foreach (var property in entry.Properties)
124124
{

0 commit comments

Comments
 (0)