using AutoMapper; using DigitalData.Core.Application; using DigitalData.Core.DTO; using EnvelopeGenerator.Application.Contracts; using EnvelopeGenerator.Application.DTOs; using EnvelopeGenerator.Application.Resources; using EnvelopeGenerator.Domain.Entities; using EnvelopeGenerator.Infrastructure.Contracts; using Microsoft.Extensions.Logging; namespace EnvelopeGenerator.Application.Services { public class EnvelopeService : BasicCRUDService, IEnvelopeService { public EnvelopeService(IEnvelopeRepository repository, IMapper mapper, ILogger logger) : base(repository, mapper) { } public async Task>> ReadAllWithAsync(bool documents = false, bool history = false, bool documentReceiverElement = false) { var envelopes = await _repository.ReadAllWithAsync(documents: documents, history: history, documentReceiverElement: documentReceiverElement); var readDto = _mapper.MapOrThrow>(envelopes); return Result.Success(readDto); } public async Task> ReadByUuidAsync(string uuid, bool withDocuments = false, bool withHistory = false, bool withDocumentReceiverElement = false, bool withUser = false, bool withAll = false) { var envelope = await _repository.ReadByUuidAsync(uuid: uuid, withDocuments: withDocuments, withHistory: withHistory, withDocumentReceiverElement: withDocumentReceiverElement, withUser:withUser, withAll:withAll); if (envelope is null) return Result.Fail(); var readDto = _mapper.MapOrThrow(envelope); return Result.Success(readDto); } } }