Files
hrynco-notification-service/HrynCo.NotificationService.Services/EmailTemplates/Get/GetEmailTemplateHandler.cs
T
Anatolii Grynchuk 50828d23ec refactor: replace internal UnitOfWork with NotificationUnitOfWork and NotificationBaseRepository
- Consolidate unit of work implementation with NotificationUnitOfWork.
- Refactor repositories to use NotificationBaseRepository for consistency.
- Simplify request handlers by removing IUnitOfWork dependency.
- Update related tests and service registration.
2026-05-13 02:08:43 +03:00

33 lines
1.2 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.Get;
internal sealed class GetEmailTemplateHandler
: RequestHandler<GetEmailTemplateQuery, ServiceResult<EmailTemplate>>
{
private readonly IEmailTemplateRepository _templates;
public GetEmailTemplateHandler(
IContextualSerilogLogger<GetEmailTemplateQuery> logger,
IEmailTemplateRepository templates)
: base(logger)
{
_templates = templates;
}
protected override async Task<ServiceResult<EmailTemplate>> DoOnHandle(
GetEmailTemplateQuery request, CancellationToken cancellationToken)
{
var template = await _templates.GetAsync(
request.ServiceName, request.Key, request.LanguageCode, cancellationToken);
return template is null
? Failure<EmailTemplate>("Template not found.", ServiceErrorCode.NotFound)
: Success(template);
}
}