Refactor envelope creation logic and add IEnvelopeExecutor
Updated CreateEnvelopeCommandHandler to use IEnvelopeExecutor for managing envelope creation. Introduced CreateParmas method for parameter handling in CreateEnvelopeSQL. Corrected Dapper type mapping method name and added service registration for IEnvelopeExecutor in DependencyExtensions. Refactored SQLExecutor to enhance encapsulation. Created EnvelopeExecutor class implementing IEnvelopeExecutor for dedicated envelope operations.
This commit is contained in:
@@ -1,8 +1,6 @@
|
||||
using AutoMapper;
|
||||
using Dapper;
|
||||
using EnvelopeGenerator.Application.Contracts.SQLExecutor;
|
||||
using EnvelopeGenerator.Application.SQL;
|
||||
using EnvelopeGenerator.Domain.Entities;
|
||||
using MediatR;
|
||||
|
||||
namespace EnvelopeGenerator.Application.Envelopes.Commands;
|
||||
@@ -12,18 +10,18 @@ namespace EnvelopeGenerator.Application.Envelopes.Commands;
|
||||
/// </summary>
|
||||
public class CreateEnvelopeCommandHandler : IRequestHandler<CreateEnvelopeCommand, CreateEnvelopeResponse?>
|
||||
{
|
||||
private readonly ISQLExecutor _sqlExecutor;
|
||||
private readonly IEnvelopeExecutor _envelopeExecutor;
|
||||
|
||||
private readonly IMapper _mapper;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="sqlExecutor"></param>
|
||||
/// <param name="envelopeExecutor"></param>
|
||||
/// <param name="mapper"></param>
|
||||
public CreateEnvelopeCommandHandler(ISQLExecutor<Envelope> sqlExecutor, IMapper mapper)
|
||||
public CreateEnvelopeCommandHandler(IEnvelopeExecutor envelopeExecutor, IMapper mapper)
|
||||
{
|
||||
_sqlExecutor = sqlExecutor;
|
||||
_envelopeExecutor = envelopeExecutor;
|
||||
_mapper = mapper;
|
||||
}
|
||||
|
||||
@@ -37,7 +35,7 @@ public class CreateEnvelopeCommandHandler : IRequestHandler<CreateEnvelopeComman
|
||||
{
|
||||
int userId = request.UserId ?? throw new InvalidOperationException("UserId cannot be null when creating an envelope.");
|
||||
|
||||
var envelope = await _sqlExecutor.CreateEnvelopeAsync<Envelope>(userId, request.Title, request.Message, request.TFAEnabled, cancellationToken);
|
||||
var envelope = await _envelopeExecutor.CreateEnvelopeAsync(userId, request.Title, request.Message, request.TFAEnabled, cancellationToken);
|
||||
|
||||
return _mapper.Map<CreateEnvelopeResponse>(envelope);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user