- 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.
41 lines
1.2 KiB
C#
41 lines
1.2 KiB
C#
using AutoMapper;
|
|
using EnvelopeGenerator.Application.Interfaces.SQLExecutor;
|
|
using EnvelopeGenerator.Application.Dto;
|
|
using MediatR;
|
|
|
|
namespace EnvelopeGenerator.Application.Envelopes.Commands;
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public class CreateEnvelopeCommandHandler : IRequestHandler<CreateEnvelopeCommand, EnvelopeDto?>
|
|
{
|
|
private readonly IEnvelopeExecutor _envelopeExecutor;
|
|
|
|
private readonly IMapper _mapper;
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="envelopeExecutor"></param>
|
|
/// <param name="mapper"></param>
|
|
public CreateEnvelopeCommandHandler(IEnvelopeExecutor envelopeExecutor, IMapper mapper)
|
|
{
|
|
_envelopeExecutor = envelopeExecutor;
|
|
_mapper = mapper;
|
|
}
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="request"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
public async Task<EnvelopeDto?> Handle(CreateEnvelopeCommand request, CancellationToken cancellationToken)
|
|
{
|
|
var envelope = await _envelopeExecutor.CreateEnvelopeAsync(request.UserId, request.Title, request.Message, request.TFAEnabled, cancellationToken);
|
|
|
|
return _mapper.Map<EnvelopeDto>(envelope);
|
|
}
|
|
}
|