fix(rd21): guard career and job saves with durable revisions

This commit is contained in:
cesnimda
2026-10-23 08:07:23 +02:00
parent 8f2cad67f7
commit 12f342c09c
32 changed files with 1185 additions and 277 deletions
@@ -0,0 +1,22 @@
using Microsoft.AspNetCore.Diagnostics;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
namespace JobTrackerApi.Services;
public sealed class RevisionConflictExceptionHandler : IExceptionHandler
{
public async ValueTask<bool> TryHandleAsync(HttpContext context, Exception exception, CancellationToken cancellationToken)
{
if (exception is not DbUpdateConcurrencyException) return false;
context.Response.StatusCode = StatusCodes.Status409Conflict;
await context.Response.WriteAsJsonAsync(new ProblemDetails
{
Status = StatusCodes.Status409Conflict,
Title = "The record changed",
Detail = "Your draft was not saved. Reload and review the current record before saving again.",
Extensions = { ["code"] = "revision_conflict" },
}, cancellationToken);
return true;
}
}