using HrynCo.NotificationService.DAL.Abstract; using HrynCo.NotificationService.DAL.Abstract.Providers; using HrynCo.NotificationService.DAL.Abstract.Repositories; using HrynCo.NotificationService.Services.Core; using HrynCo.NotificationService.Services.Logging; using static HrynCo.NotificationService.Services.Core.ServiceResultHelper; namespace HrynCo.NotificationService.Services.EmailChannels.Get; internal sealed class GetEmailChannelHandler : RequestHandler> { private readonly IEmailChannelRepository _channels; public GetEmailChannelHandler( IContextualSerilogLogger logger, IUnitOfWork unitOfWork, IEmailChannelRepository channels) : base(logger, unitOfWork) { _channels = channels; } protected override async Task> DoOnHandle( GetEmailChannelQuery request, CancellationToken cancellationToken) { var channel = await _channels.GetByIdAsync(request.Id, cancellationToken); return channel is null ? Failure("Email channel not found.", ServiceErrorCode.NotFound) : Success(channel); } }