using AutoMapper; using DigitalData.Core.Application; using DigitalData.Core.Contracts.Application; using DigitalData.Core.Contracts.CultureServices; using EnvelopeGenerator.Application.Contracts; using EnvelopeGenerator.Application.DTOs; using EnvelopeGenerator.Domain.Entities; using EnvelopeGenerator.Infrastructure.Contracts; namespace EnvelopeGenerator.Application.Services { public class EnvelopeService : BasicCRUDService, IEnvelopeService { public EnvelopeService(IEnvelopeRepository repository, IKeyTranslationService translationService, IMapper mapper) : base(repository, translationService, mapper) { } public async Task>> ReadAllWithAsync(bool documents = false, bool receivers = false, bool history = false, bool documentReceiverElement = false) { var envelopes = await _repository.ReadAllWithAsync(documents: documents, receivers: receivers, history: history, documentReceiverElement: documentReceiverElement); var readDto = _mapper.MapOrThrow>(envelopes); return Successful(readDto); } public async Task> ReadByUuidAsync(string uuid, bool withDocuments = false, bool withReceivers = false, bool withHistory = false, bool withDocumentReceiverElement = false) { var envelope = await _repository.ReadByUuidAsync(uuid: uuid, withDocuments: withDocuments, withReceivers: withReceivers, withHistory: withHistory, withDocumentReceiverElement: withDocumentReceiverElement); if (envelope is null) return Failed(); var readDto = _mapper.MapOrThrow(envelope); return Successful(readDto); } } }