Introduced a new feature for submitting signatures, including backend and frontend changes. Added `SignatureSubmitDto` and `SubmitAsync` in `SignatureService` to handle signature data submission. Implemented a new `Submit` endpoint in `SignatureController` to validate and process signature payloads. Updated pipeline behaviors to include `SaveSignatureBehavior` and adjusted the execution order. Enhanced query logic in `EnvelopeReceiverResolutionBehavior` and `SaveSignatureBehavior` to align with the updated data model. Refactored `EGDbContext` to improve trigger handling and logging. Updated `ReceiverSignedPage.razor` to integrate `SignatureService` and handle submission errors gracefully. Adjusted application URLs in `launchSettings.json` and added new database triggers in `appsettings.json`.
59 lines
2.1 KiB
C#
59 lines
2.1 KiB
C#
using AutoMapper;
|
|
using DigitalData.Core.Abstraction.Application.Repository;
|
|
using DigitalData.Core.Exceptions;
|
|
using EnvelopeGenerator.Application.Common.Dto.EnvelopeReceiver;
|
|
using EnvelopeGenerator.Application.Common.Extensions;
|
|
using EnvelopeGenerator.Application.DocReceiverElements.Commands;
|
|
using EnvelopeGenerator.Domain.Entities;
|
|
using MediatR;
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
namespace EnvelopeGenerator.Application.DocReceiverElements.Behaviors;
|
|
|
|
/// <summary>
|
|
/// Pipeline behavior that resolves and validates EnvelopeReceiver.
|
|
/// Executes FIRST in the signing process - before all other behaviors.
|
|
/// If EnvelopeReceiver is not provided, it queries the database using EnvelopeReceiverQueryBase parameters.
|
|
/// </summary>
|
|
public class EnvelopeReceiverResolutionBehavior : IPipelineBehavior<SigningCommand, Unit>
|
|
{
|
|
private readonly IRepository<EnvelopeReceiver> _erRepo;
|
|
private readonly IMapper _mapper;
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="erRepo"></param>
|
|
/// <param name="mapper"></param>
|
|
public EnvelopeReceiverResolutionBehavior(IRepository<EnvelopeReceiver> erRepo, IMapper mapper)
|
|
{
|
|
_erRepo = erRepo;
|
|
_mapper = mapper;
|
|
}
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="request"></param>
|
|
/// <param name="next"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
public async Task<Unit> Handle(SigningCommand request, RequestHandlerDelegate<Unit> next, CancellationToken cancellationToken)
|
|
{
|
|
// If EnvelopeReceiver is not provided, query it from database
|
|
if (request.EnvelopeReceiver is null)
|
|
{
|
|
var er = await _erRepo.Query
|
|
.Where(request, notnull: true)
|
|
.Include(x => x.Envelope)
|
|
.Include(x => x.Receiver)
|
|
.SingleOrDefaultAsync(cancellationToken)
|
|
?? throw new NotFoundException("EnvelopeReceiver not found");
|
|
|
|
request.SetEnvelopeReceiver(_mapper.Map<EnvelopeReceiverDto>(er));
|
|
}
|
|
|
|
return await next(cancellationToken);
|
|
}
|
|
}
|