ReadByName in EmailTemplate Repositroy und Dienst hinzugefügt.

This commit is contained in:
Developer 02
2024-05-17 13:59:40 +02:00
parent 2e66129485
commit bc6972bcfb
6 changed files with 56 additions and 13 deletions

View File

@@ -6,6 +6,9 @@ using EnvelopeGenerator.Application.DTOs;
using EnvelopeGenerator.Domain.Entities;
using EnvelopeGenerator.Infrastructure.Contracts;
using EnvelopeGenerator.Application.Resources;
using static EnvelopeGenerator.Common.Constants;
using DigitalData.Core.DTO;
using Microsoft.Extensions.Logging;
namespace EnvelopeGenerator.Application.Services
{
@@ -15,5 +18,15 @@ namespace EnvelopeGenerator.Application.Services
: base(repository, localizer, mapper)
{
}
public async Task<DataResult<EmailTemplateDto>> ReadByNameAsync(EmailTemplateType type)
{
var temp = await _repository.ReadByNameAsync(type);
return temp is null
? Result.Fail<EmailTemplateDto>()
.Message(Key.InnerServiceError)
.Notice(LogLevel.Error, Flag.DataIntegrityIssue, $"EmailTemplateType '{type}' is not found in DB. Please, define required e-mail template.")
: Result.Success(_mapper.MapOrThrow<EmailTemplateDto>(temp));
}
}
}