- Added `EnvelopeGenerator.Domain.Constants` in multiple files, replacing `Domain.Constants.EnvelopeStatus` with `EnvelopeStatus` for improved readability. - Modified `CreateEnvelopeCommandHandler.cs` to directly use `request.UserId`, eliminating unnecessary local variable assignment. - Identified potential duplication in query logic within `ReceiverAlreadySignedQuery.cs`. - Updated `IEnvelopeService`, `EnvelopeReceiverService`, and `EnvelopeService` to ensure consistent usage of the simplified `EnvelopeStatus`. - Overall, these changes enhance code maintainability and clarity.
77 lines
3.1 KiB
C#
77 lines
3.1 KiB
C#
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;
|
|
using EnvelopeGenerator.Domain.Constants;
|
|
|
|
namespace EnvelopeGenerator.Application.Services;
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
[Obsolete("Use MediatR")]
|
|
public class EnvelopeService : BasicCRUDService<IEnvelopeRepository, EnvelopeDto, Envelope, int>, IEnvelopeService
|
|
{
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="repository"></param>
|
|
/// <param name="mapper"></param>
|
|
public EnvelopeService(IEnvelopeRepository repository, IMapper mapper)
|
|
: base(repository, mapper)
|
|
{
|
|
}
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="documents"></param>
|
|
/// <param name="history"></param>
|
|
/// <param name="documentReceiverElement"></param>
|
|
/// <returns></returns>
|
|
public async Task<DataResult<IEnumerable<EnvelopeDto>>> 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<IEnumerable<EnvelopeDto>>(envelopes);
|
|
return Result.Success(readDto);
|
|
}
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="uuid"></param>
|
|
/// <param name="withDocuments"></param>
|
|
/// <param name="withHistory"></param>
|
|
/// <param name="withDocumentReceiverElement"></param>
|
|
/// <param name="withUser"></param>
|
|
/// <param name="withAll"></param>
|
|
/// <returns></returns>
|
|
public async Task<DataResult<EnvelopeDto>> 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<EnvelopeDto>();
|
|
|
|
var readDto = _mapper.Map<EnvelopeDto>(envelope);
|
|
return Result.Success(readDto);
|
|
}
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="userId"></param>
|
|
/// <param name="min_status"></param>
|
|
/// <param name="max_status"></param>
|
|
/// <param name="ignore_statuses"></param>
|
|
/// <returns></returns>
|
|
public async Task<DataResult<IEnumerable<EnvelopeDto>>> 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<IEnumerable<EnvelopeDto>>(users);
|
|
return Result.Success(readDto);
|
|
}
|
|
} |