Files
hrynco-notification-service/HrynCo.NotificationService.Services/EmailTemplates/GetAll/GetAllEmailTemplatesHandler.cs
T

29 lines
1.1 KiB
C#

using HrynCo.NotificationService.DAL.Abstract.Repositories;
using HrynCo.NotificationService.DAL.Abstract.Templates;
using HrynCo.NotificationService.Services.Core;
using HrynCo.NotificationService.Services.Logging;
using static HrynCo.NotificationService.Services.Core.ServiceResultHelper;
namespace HrynCo.NotificationService.Services.EmailTemplates.GetAll;
internal sealed class GetAllEmailTemplatesHandler
: RequestHandler<GetAllEmailTemplatesQuery, ServiceResult<IReadOnlyList<EmailTemplate>>>
{
private readonly IEmailTemplateRepository _templates;
public GetAllEmailTemplatesHandler(
IContextualSerilogLogger<GetAllEmailTemplatesQuery> logger,
IEmailTemplateRepository templates)
: base(logger)
{
_templates = templates;
}
protected override async Task<ServiceResult<IReadOnlyList<EmailTemplate>>> DoOnHandle(
GetAllEmailTemplatesQuery request, CancellationToken cancellationToken)
{
var templates = await _templates.GetAllAsync(request.ServiceName, request.Key, cancellationToken);
return Success(templates);
}
}