using System.Collections.Concurrent; using Big.Application; using Big.Domain; namespace Big.Infrastructure; /// /// In-memory 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. /// public sealed class InMemoryRegistrationStore : IRegistrationStore { private readonly ConcurrentDictionary _byId = new(); public Task SaveAsync(Registration registration, CancellationToken ct = default) { ArgumentNullException.ThrowIfNull(registration); _byId[registration.Id] = registration; return Task.CompletedTask; } public Task GetAsync(RegistrationId id, CancellationToken ct = default) => Task.FromResult(_byId.GetValueOrDefault(id)); public Task FindOpenByBsnAsync(string bsn, CancellationToken ct = default) => Task.FromResult(_byId.Values.FirstOrDefault(r => r.Bsn == bsn && r.Status is RegistrationStatus.Ingediend or RegistrationStatus.InBehandeling)); public Task> FindDueForHerregistratieReminderAsync( DateTimeOffset asOf, CancellationToken ct = default) => Task.FromResult>( _byId.Values.Where(r => r.HerregistratieReminderDue(asOf)).ToList()); }