diff --git a/EnvelopeGenerator.Application/Common/Notifications/RemoveSignature/Handlers/RemoveAnnotationHandler.cs b/EnvelopeGenerator.Application/Common/Notifications/RemoveSignature/Handlers/RemoveAnnotationHandler.cs index 0142b352..30251d84 100644 --- a/EnvelopeGenerator.Application/Common/Notifications/RemoveSignature/Handlers/RemoveAnnotationHandler.cs +++ b/EnvelopeGenerator.Application/Common/Notifications/RemoveSignature/Handlers/RemoveAnnotationHandler.cs @@ -8,13 +8,13 @@ namespace EnvelopeGenerator.Application.Common.Notifications.RemoveSignature.Han /// public class RemoveAnnotationHandler : INotificationHandler { - private readonly IRepository _repo; + private readonly IRepository _repo; /// /// /// /// - public RemoveAnnotationHandler(IRepository repository) + public RemoveAnnotationHandler(IRepository repository) { _repo = repository; } @@ -27,6 +27,6 @@ public class RemoveAnnotationHandler : INotificationHandler public async Task Handle(RemoveSignatureNotification notification, CancellationToken cancel) { - await _repo.DeleteAsync(s => s.EnvelopeId == notification.EnvelopeId, cancel); + await _repo.DeleteAsync(s => s.Envelope!.Uuid == notification.EnvelopeUuid, cancel); } } \ No newline at end of file diff --git a/EnvelopeGenerator.Application/Common/Notifications/RemoveSignature/Handlers/RemoveHistoryHandler.cs b/EnvelopeGenerator.Application/Common/Notifications/RemoveSignature/Handlers/RemoveHistoryHandler.cs index 54e5e087..2f40bdc4 100644 --- a/EnvelopeGenerator.Application/Common/Notifications/RemoveSignature/Handlers/RemoveHistoryHandler.cs +++ b/EnvelopeGenerator.Application/Common/Notifications/RemoveSignature/Handlers/RemoveHistoryHandler.cs @@ -12,13 +12,13 @@ namespace EnvelopeGenerator.Application.Common.Notifications.RemoveSignature.Han /// public class RemoveHistoryHandler : INotificationHandler { - private readonly IRepository _repo; + private readonly IRepository _repo; /// /// /// /// - public RemoveHistoryHandler(IRepository repository) + public RemoveHistoryHandler(IRepository repository) { _repo = repository; } @@ -31,9 +31,9 @@ public class RemoveHistoryHandler : INotificationHandler public async Task Handle(RemoveSignatureNotification notification, CancellationToken cancel) { - await _repo.DeleteAsync(hists + await _repo.DeleteAsync(hists => hists - .Where(hist => hist.EnvelopeId == notification.EnvelopeId) + .Where(hist => hist.Envelope!.Uuid == notification.EnvelopeUuid) .Where(hist => hist.Status == EnvelopeStatus.DocumentSigned) , cancel); } diff --git a/EnvelopeGenerator.Application/Common/Notifications/RemoveSignature/RemoveSignatureNotification.cs b/EnvelopeGenerator.Application/Common/Notifications/RemoveSignature/RemoveSignatureNotification.cs index 0abaf178..b896870b 100644 --- a/EnvelopeGenerator.Application/Common/Notifications/RemoveSignature/RemoveSignatureNotification.cs +++ b/EnvelopeGenerator.Application/Common/Notifications/RemoveSignature/RemoveSignatureNotification.cs @@ -5,5 +5,5 @@ namespace EnvelopeGenerator.Application.Common.Notifications.RemoveSignature; /// /// /// -/// -public record RemoveSignatureNotification(int EnvelopeId) : INotification; \ No newline at end of file +/// +public record RemoveSignatureNotification(string EnvelopeUuid) : INotification; \ No newline at end of file diff --git a/EnvelopeGenerator.Web/Controllers/Test/TestAnnotationController.cs b/EnvelopeGenerator.Web/Controllers/Test/TestAnnotationController.cs new file mode 100644 index 00000000..c04d0485 --- /dev/null +++ b/EnvelopeGenerator.Web/Controllers/Test/TestAnnotationController.cs @@ -0,0 +1,30 @@ +using EnvelopeGenerator.Application.Common.Extensions; +using EnvelopeGenerator.Application.Common.Notifications.RemoveSignature; +using MediatR; +using Microsoft.AspNetCore.Mvc; + +namespace EnvelopeGenerator.Web.Controllers.Test; + +[Route("api/[controller]")] +[ApiController] +public class TestAnnotationController : ControllerBase +{ + private IMediator _mediator; + + public TestAnnotationController(IMediator mediator) + { + _mediator = mediator; + } + + [HttpDelete("{envelopeKey}")] + public async Task Delete([FromRoute] string envelopeKey) + { + var uuid = envelopeKey.GetEnvelopeUuid(); + + if (uuid == null) + return BadRequest(); + + await _mediator.Publish(new RemoveSignatureNotification(uuid)); + return Ok(); + } +} \ No newline at end of file