Backend half of S-26. The domain gains IRegistrationStore.FindOpenByBsnAsync (the citizen's non-terminal INGEDIEND/IN_BEHANDELING registration) + GET /registrations/current?bsn=; the BFF adds owner-scoped GET /self-service/registrations (bsn from the DigiD token) returning that registration or 204 when none. Regenerated services/bff/openapi.json for the new endpoint (the api-client is generated from it). Store + BFF endpoint unit tests; acceptance/BFF fakes updated for the new members. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
30 lines
1.2 KiB
C#
30 lines
1.2 KiB
C#
using System.Collections.Concurrent;
|
|
using Big.Application;
|
|
using Big.Domain;
|
|
|
|
namespace Big.Infrastructure;
|
|
|
|
/// <summary>
|
|
/// In-memory <see cref="IRegistrationStore"/> for the minimal slice (ADR-0009). The walking
|
|
/// skeleton's read path is the projection (S-06), not this store, so durable domain persistence is a
|
|
/// documented follow-up. Registered as a singleton so the submit endpoint and the worker share it.
|
|
/// </summary>
|
|
public sealed class InMemoryRegistrationStore : IRegistrationStore
|
|
{
|
|
private readonly ConcurrentDictionary<RegistrationId, Registration> _byId = new();
|
|
|
|
public Task SaveAsync(Registration registration, CancellationToken ct = default)
|
|
{
|
|
ArgumentNullException.ThrowIfNull(registration);
|
|
_byId[registration.Id] = registration;
|
|
return Task.CompletedTask;
|
|
}
|
|
|
|
public Task<Registration?> GetAsync(RegistrationId id, CancellationToken ct = default)
|
|
=> Task.FromResult(_byId.GetValueOrDefault(id));
|
|
|
|
public Task<Registration?> FindOpenByBsnAsync(string bsn, CancellationToken ct = default)
|
|
=> Task.FromResult(_byId.Values.FirstOrDefault(r =>
|
|
r.Bsn == bsn && r.Status is RegistrationStatus.Ingediend or RegistrationStatus.InBehandeling));
|
|
}
|