using AutoMapper; using DigitalData.Core.Application; using DigitalData.Core.Abstraction.Application.DTO; using EnvelopeGenerator.Application.Interfaces.Services; using EnvelopeGenerator.Application.Dto; using EnvelopeGenerator.Domain.Entities; using EnvelopeGenerator.Application.Interfaces.Repositories; namespace EnvelopeGenerator.Application.Services; /// /// /// [Obsolete("Use MediatR")] public class EnvelopeService : BasicCRUDService, IEnvelopeService { /// /// /// /// /// public EnvelopeService(IEnvelopeRepository repository, IMapper mapper) : 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.Map>(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.Map(envelope); return Result.Success(readDto); } /// /// /// /// /// /// /// /// public async Task>> ReadByUserAsync(int userId, int? min_status = null, int? max_status = null, params int[] ignore_statuses) { var users = await _repository.ReadByUserAsync(userId: userId, min_status: min_status, max_status: max_status, ignore_statuses: ignore_statuses); var readDto = _mapper.Map>(users); return Result.Success(readDto); } }