Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Aragas committed May 27, 2024
1 parent 4ac8dbc commit fead59c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@
if (save && _datagridPagingRef?.Value is not null)
{
var updatedCrashReport = _datagridPagingRef.Value with { };
if (await _crashReportsClient.UpdateAsync(updatedCrashReport.Id, updatedCrashReport.Status, updatedCrashReport.Comment) is { Error: null })
if (await _crashReportsClient.UpdateAsync(updatedCrashReport.Id, new(updatedCrashReport.Status, updatedCrashReport.Comment)) is { Error: null })
{
await _notificationService.Success("Saved Crash Report!", "Success!");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ public sealed record CrashReportModel2
public string Comment { get; init; } = string.Empty;
}

public sealed record CrashReportUpdateModel
{
public required CrashReportStatus? Status { get; init; }
public required string? Comment { get; init; }
}


private readonly ILogger _logger;
private readonly IUnitOfWorkFactory _unitOfWorkFactory;
Expand All @@ -49,7 +55,7 @@ public CrashReportsController(ILogger<CrashReportsController> logger, IUnitOfWor
}

[HttpPatch]
public async Task<ApiResult<string?>> UpdateAsync([FromQuery, Required] CrashReportId crashReportId, [FromQuery] CrashReportStatus? status, [FromQuery] string? comment, [BindUserId] NexusModsUserId userId, [BindTenant] TenantId tenant)
public async Task<ApiResult<string?>> UpdateAsync([FromQuery, Required] CrashReportId crashReportId, [FromBody] CrashReportUpdateModel updateModel, [BindUserId] NexusModsUserId userId, [BindTenant] TenantId tenant)
{
await using var unitOfRead = _unitOfWorkFactory.CreateUnitOfRead();
await using var unitOfWrite = _unitOfWorkFactory.CreateUnitOfWrite();
Expand All @@ -63,8 +69,8 @@ public CrashReportsController(ILogger<CrashReportsController> logger, IUnitOfWor
NexusModsUserId = userId,
NexusModsUser = unitOfWrite.UpsertEntityFactory.GetOrCreateNexusModsUser(userId),
CrashReportId = crashReportId,
Status = status ?? existingEntity?.Status ?? CrashReportStatus.New,
Comment = comment ?? existingEntity?.Comment ?? string.Empty,
Status = updateModel.Status ?? existingEntity?.Status ?? CrashReportStatus.New,
Comment = updateModel.Comment ?? existingEntity?.Comment ?? string.Empty,
};
unitOfWrite.NexusModsUserToCrashReports.Upsert(entity);

Expand Down

0 comments on commit fead59c

Please sign in to comment.