using AutoMapper; using DigitalData.Core.Application; using EnvelopeGenerator.Application.DTOs; using EnvelopeGenerator.Domain.Entities; using EnvelopeGenerator.Application.Contracts.Repositories; using static EnvelopeGenerator.Common.Constants; using DigitalData.Core.DTO; using Microsoft.Extensions.Logging; using EnvelopeGenerator.Application.Contracts.Services; namespace EnvelopeGenerator.Application.Services; public class EmailTemplateService : BasicCRUDService, IEmailTemplateService { public EmailTemplateService(IEmailTemplateRepository repository, IMapper mapper) : base(repository, mapper) { } public async Task> ReadByNameAsync(EmailTemplateType type) { var temp = await _repository.ReadByNameAsync(type); return temp is null ? Result.Fail() .Message(Key.InnerServiceError) .Notice(LogLevel.Error, Flag.DataIntegrityIssue, $"EmailTemplateType '{type}' is not found in DB. Please, define required e-mail template.") : Result.Success(_mapper.Map(temp)); } }