Skip to content

Commit

Permalink
fix: grid area consolidation audit (#3868)
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelmajgaard authored Jan 3, 2025
1 parent 671bca2 commit a95fed2
Showing 1 changed file with 11 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ protected override void Configure(IObjectTypeDescriptor<GridAreaAuditedChangeAud

descriptor
.Field("currentOwner")
.Resolve(async (ctx, ct) =>
.Resolve(async (ctx, _) =>
{
var parent = ctx.Parent<GridAreaAuditedChangeAuditLogDto>();
if (parent.Change != GridAreaAuditedChange.ConsolidationRequested && parent.Change != GridAreaAuditedChange.ConsolidationCompleted && parent.CurrentValue is not null)
if (parent.Change is GridAreaAuditedChange.ConsolidationRequested or GridAreaAuditedChange.ConsolidationCompleted && parent.CurrentValue is not null)
{
var currentValue = JsonSerializer.Deserialize<ActorConsolidationActorAndDate>(parent.CurrentValue) ?? throw new InvalidOperationException("Could not deserialize current value for Consolidation audit log in GridAreaAuditedChangeAuditLogDtoType");
return await GetActorNameAsync(parent.Change, currentValue.ActorId.ToString(), ctx);
Expand All @@ -53,44 +53,31 @@ protected override void Configure(IObjectTypeDescriptor<GridAreaAuditedChangeAud

descriptor
.Field("previousOwner")
.Resolve(async (ctx, ct) =>
.Resolve(async (ctx, _) =>
{
var parent = ctx.Parent<GridAreaAuditedChangeAuditLogDto>();
if (parent.Change != GridAreaAuditedChange.ConsolidationRequested && parent.Change != GridAreaAuditedChange.ConsolidationCompleted && parent.PreviousValue is not null)
if (parent.Change is GridAreaAuditedChange.ConsolidationRequested or GridAreaAuditedChange.ConsolidationCompleted && parent.PreviousValue is not null)
{
try
{
var previousValue = JsonSerializer.Deserialize<ActorConsolidationActorAndDate>(parent.PreviousValue) ?? throw new InvalidOperationException("Could not deserialize current value for Consolidation audit log in GridAreaAuditedChangeAuditLogDtoType");
return await GetActorNameAsync(parent.Change, previousValue.ActorId.ToString(), ctx);
}
catch (System.Exception)
{
return null;
}
var previousValue = JsonSerializer.Deserialize<ActorConsolidationActorAndDate>(parent.PreviousValue) ?? throw new InvalidOperationException("Could not deserialize current value for Consolidation audit log in GridAreaAuditedChangeAuditLogDtoType");
return await GetActorNameAsync(parent.Change, previousValue.ActorId.ToString(), ctx);
}

return await GetActorNameAsync(parent.Change, parent.PreviousValue, ctx);
});

descriptor
.Field("consolidatedAt")
.Resolve((ctx, ct) =>
.Resolve((ctx, _) =>
{
var parent = ctx.Parent<GridAreaAuditedChangeAuditLogDto>();
if (parent.Change != GridAreaAuditedChange.ConsolidationRequested && parent.Change != GridAreaAuditedChange.ConsolidationCompleted && parent.CurrentValue is not null)
{
try
var parent = ctx.Parent<GridAreaAuditedChangeAuditLogDto>();

if (parent.Change is GridAreaAuditedChange.ConsolidationRequested or GridAreaAuditedChange.ConsolidationCompleted && parent.CurrentValue is not null)
{
var currentValue = JsonSerializer.Deserialize<ActorConsolidationActorAndDate>(parent.CurrentValue) ?? throw new InvalidOperationException("Could not deserialize current value for Consolidation audit log in GridAreaAuditedChangeAuditLogDtoType");
return (DateTimeOffset?)currentValue.ConsolidateAt;
}
catch (System.Exception)
{
return null;
}
}

return null;
return null;
});
}

Expand Down

0 comments on commit a95fed2

Please sign in to comment.