From 7693a4a85a508f6228081ee8acc6a19624e42ac8 Mon Sep 17 00:00:00 2001 From: Niek Otten Date: Tue, 14 Jul 2026 17:24:46 +0200 Subject: [PATCH] feat(domain): expose POST /registrations/{id}/decide for the beoordeling (refs #13) The behandel-portal's decision reaches the domain here (via the BFF, later slices): goedkeuren/afwijzen, idempotent, superseding the temporary /approve endpoint. Co-Authored-By: Claude Opus 4.8 (1M context) --- services/domain/Big.Api/Program.cs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/services/domain/Big.Api/Program.cs b/services/domain/Big.Api/Program.cs index c180da8..eb26a17 100644 --- a/services/domain/Big.Api/Program.cs +++ b/services/domain/Big.Api/Program.cs @@ -24,6 +24,7 @@ builder.Services.AddHttpClient(); builder.Services.AddScoped(); builder.Services.AddScoped(); +builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); @@ -55,6 +56,22 @@ app.MapPost("/registrations/{id}/approve", async (string id, ApproveRegistration return Results.NoContent(); }); +// The behandelaar's beoordeling (S-12): decide a registration goedkeuren (→ INGESCHREVEN, sets the +// zaak's final status via the ACL) or afwijzen (→ AFGEWEZEN). Idempotent. This is the domain contract +// the behandel-portal's decision reaches through the BFF; it supersedes the temporary /approve above, +// which is retired once the portal lands. +app.MapPost("/registrations/{id}/decide", async (string id, DecideRequest body, BeoordeelRegistratie beoordeel, CancellationToken ct) => +{ + if (!Guid.TryParse(id, out var guid)) + return Results.NotFound(); + + if (!Enum.TryParse(body.Besluit, ignoreCase: true, out var besluit)) + return Results.BadRequest(new { error = $"Unknown besluit '{body.Besluit}'. Expected 'goedkeuren' or 'afwijzen'." }); + + await beoordeel.HandleAsync(new BeoordeelRegistratieCommand(new RegistrationId(guid), besluit), ct); + return Results.NoContent(); +}); + // Read a registration. Its zaak URL appears once the worker has opened the zaak (eventually). app.MapGet("/registrations/{id}", async (string id, IRegistrationStore store, CancellationToken ct) => { @@ -72,6 +89,8 @@ await app.RunAsync(); public sealed record SubmitRegistrationRequest(string Bsn); +public sealed record DecideRequest(string Besluit); + public sealed record RegistrationResponse(string RegistrationId, string Status, string? ZaakUrl); public partial class Program;