using ErsatzTV.Core.Domain; using ErsatzTV.Core.Interfaces.Repositories; namespace ErsatzTV.Application.Configuration; public class GetPlayoutSettingsHandler : IRequestHandler { private readonly IConfigElementRepository _configElementRepository; public GetPlayoutSettingsHandler(IConfigElementRepository configElementRepository) => _configElementRepository = configElementRepository; public async Task Handle(GetPlayoutSettings request, CancellationToken cancellationToken) { Option daysToBuild = await _configElementRepository.GetValue( ConfigElementKey.PlayoutDaysToBuild, cancellationToken); Option skipMissingItems = await _configElementRepository.GetValue(ConfigElementKey.PlayoutSkipMissingItems, cancellationToken); Option scriptedScheduleTimeoutSeconds = await _configElementRepository.GetValue( ConfigElementKey.PlayoutScriptedScheduleTimeoutSeconds, cancellationToken); return new PlayoutSettingsViewModel { DaysToBuild = await daysToBuild.IfNoneAsync(2), SkipMissingItems = await skipMissingItems.IfNoneAsync(false), ScriptedScheduleTimeoutSeconds = await scriptedScheduleTimeoutSeconds.IfNoneAsync(30) }; } }