Files
hrynco-notification-service/HrynCo.NotificationService.Worker.Services/EmailProcessing/EmailTemplateService.cs
T
agrynco 2757869176 feat: consume transactional email notifications
Add contract validation, SMTP delivery results, terminal failure context, neutral development seeding, and local Docker setup.

Ref: IT-1033
2026-08-04 12:32:28 +03:00

36 lines
1.2 KiB
C#

namespace HrynCo.NotificationService.Worker.Services.EmailProcessing;
using HrynCo.NotificationService.DAL.Abstract.Repositories;
using HrynCo.NotificationService.DAL.Abstract.Templates;
internal sealed class EmailTemplateService : IEmailTemplateService
{
private readonly IEmailTemplateRepository _templateRepository;
public EmailTemplateService(IEmailTemplateRepository templateRepository)
{
_templateRepository = templateRepository;
}
public async Task<EmailTemplate> GetAsync(
string serviceName,
string templateKey,
string? languageCode,
CancellationToken cancellationToken)
{
if (string.IsNullOrWhiteSpace(languageCode))
throw new InvalidDataException("LanguageCode is required.");
string lang = languageCode.Trim().ToLowerInvariant();
EmailTemplate? template = await _templateRepository.GetAsync(
serviceName,
templateKey,
lang,
cancellationToken);
return template
?? throw new InvalidOperationException(
$"Template not found: service='{serviceName}' key='{templateKey}' language='{lang}'.");
}
}