using AutoMapper;
using DigitalData.Core.Application;
using DigitalData.Core.Abstraction.Application.DTO;
using EnvelopeGenerator.Domain.Entities;
using EnvelopeGenerator.Domain.Constants;
using EnvelopeGenerator.Application.Common.Dto;
using EnvelopeGenerator.Application.Common.Interfaces.Repositories;
using EnvelopeGenerator.Application.Common.Interfaces.Services;
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, EnvelopeStatus? min_status = null, EnvelopeStatus? max_status = null, params EnvelopeStatus[] 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);
}
}