From ecc75529517607cd30222bbfef8c710c93468f78 Mon Sep 17 00:00:00 2001 From: TekH Date: Mon, 13 Oct 2025 17:15:00 +0200 Subject: [PATCH] refactor: move CreateAnnotationCommand extension to separate static class --- .../Commands/CreateAnnotationCommand.cs | 19 +++++++++++++++++-- .../Test/TestAnnotationController.cs | 10 +++++++++- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/EnvelopeGenerator.Application/Annotations/Commands/CreateAnnotationCommand.cs b/EnvelopeGenerator.Application/Annotations/Commands/CreateAnnotationCommand.cs index 87758a4f..dd333602 100644 --- a/EnvelopeGenerator.Application/Annotations/Commands/CreateAnnotationCommand.cs +++ b/EnvelopeGenerator.Application/Annotations/Commands/CreateAnnotationCommand.cs @@ -1,5 +1,4 @@ -using AngleSharp.Dom; -using DigitalData.Core.Abstraction.Application.Repository; +using DigitalData.Core.Abstraction.Application.Repository; using EnvelopeGenerator.Application.Common.Extensions; using EnvelopeGenerator.Application.Common.Query; using EnvelopeGenerator.Domain.Entities; @@ -48,6 +47,22 @@ public record CreateAnnotationCommand : EnvelopeReceiverQueryBase, IRequest _lazyPSPDFKitInstant.Value; } +/// +/// +/// +public static class CreateAnnotationCommandExtensions +{ + /// + /// + /// + /// + /// + /// + /// + public static Task> CreateAnnotation(this ISender sender, string envelopeKey, CancellationToken cancel = default) + => sender.Send(new CreateAnnotationCommand() { Key = envelopeKey }, cancel); +} + /// /// /// diff --git a/EnvelopeGenerator.Web/Controllers/Test/TestAnnotationController.cs b/EnvelopeGenerator.Web/Controllers/Test/TestAnnotationController.cs index c04d0485..fc38b708 100644 --- a/EnvelopeGenerator.Web/Controllers/Test/TestAnnotationController.cs +++ b/EnvelopeGenerator.Web/Controllers/Test/TestAnnotationController.cs @@ -1,4 +1,5 @@ -using EnvelopeGenerator.Application.Common.Extensions; +using EnvelopeGenerator.Application.Annotations.Commands; +using EnvelopeGenerator.Application.Common.Extensions; using EnvelopeGenerator.Application.Common.Notifications.RemoveSignature; using MediatR; using Microsoft.AspNetCore.Mvc; @@ -27,4 +28,11 @@ public class TestAnnotationController : ControllerBase await _mediator.Publish(new RemoveSignatureNotification(uuid)); return Ok(); } + + [HttpPost("{envelopeKey}")] + public async Task Create([FromRoute] string envelopeKey, CancellationToken cancel) + { + var annot = await _mediator.CreateAnnotation(envelopeKey, cancel); + return Ok(annot); + } } \ No newline at end of file