using ErsatzTV.Core.Domain; using ErsatzTV.Core.Interfaces.Repositories; namespace ErsatzTV.Application.HDHR; public class GetHDHRUUIDHandler : IRequestHandler { private readonly IConfigElementRepository _configElementRepository; public GetHDHRUUIDHandler(IConfigElementRepository configElementRepository) => _configElementRepository = configElementRepository; public async Task Handle(GetHDHRUUID request, CancellationToken cancellationToken) { Option maybeGuid = await _configElementRepository.GetValue(ConfigElementKey.HDHRUUID); return await maybeGuid.IfNoneAsync( async () => { Guid guid = Guid.NewGuid(); await _configElementRepository.Upsert(ConfigElementKey.HDHRUUID, guid); return guid; }); } }