diff --git a/EnvelopeGenerator.Application/Pdf/BurnPdfCommand.cs b/EnvelopeGenerator.Application/Pdf/BurnPdfCommand.cs index 070c2d92..147a1abc 100644 --- a/EnvelopeGenerator.Application/Pdf/BurnPdfCommand.cs +++ b/EnvelopeGenerator.Application/Pdf/BurnPdfCommand.cs @@ -17,14 +17,12 @@ namespace EnvelopeGenerator.Application.Pdf; /// /// /// -public class BurnPdfCommand : IRequest -{ -} +public record BurnPdfCommand(byte[] SourceBuffer, List InstantJSONList, int EnvelopeId) : IRequest; /// /// /// -public class BurnPdfCommandHandler : IRequestHandler +public class BurnPdfCommandHandler : IRequestHandler { /// /// @@ -52,26 +50,6 @@ public class BurnPdfCommandHandler : IRequestHandler _logger = logger; } - /// - /// - /// - /// - /// - /// - /// - public byte[] BurnAnnotsToPDF(byte[] pSourceBuffer, List pInstantJSONList, int envelopeId) - { - // read the elements of envelope with their annotations - var elements = _signRepo - .Where(sig => sig.Document.EnvelopeId == envelopeId) - .Include(sig => sig.Annotations) - .ToList(); - - return elements.Any() - ? BurnElementAnnotsToPDF(pSourceBuffer, elements) - : BurnInstantJSONAnnotsToPDF(pSourceBuffer, pInstantJSONList); - } - /// /// /// @@ -347,7 +325,8 @@ public class BurnPdfCommandHandler : IRequestHandler _manager.AddFreeHandAnnot(oColor, oPoints); } } - private void AddInkAnnotation(Annotation pAnnotation) + + private void AddInkAnnotation(Annotation pAnnotation) { var oSegments = pAnnotation.Lines?.Points; var oColor = ColorTranslator.FromHtml(pAnnotation.StrokeColor ?? "#000000"); @@ -388,11 +367,19 @@ public class BurnPdfCommandHandler : IRequestHandler /// /// /// - /// + /// /// /// - public Task Handle(BurnPdfCommand request, CancellationToken cancellationToken) + public async Task Handle(BurnPdfCommand request, CancellationToken cancel) { - throw new NotImplementedException(); + // read the elements of envelope with their annotations + var elements = await _signRepo + .Where(sig => sig.Document.EnvelopeId == request.EnvelopeId) + .Include(sig => sig.Annotations) + .ToListAsync(cancel); + + return elements.Count > 0 + ? BurnElementAnnotsToPDF(request.SourceBuffer, elements) + : BurnInstantJSONAnnotsToPDF(request.SourceBuffer, request.InstantJSONList); } } \ No newline at end of file diff --git a/EnvelopeGenerator.Domain/Entities/Signature.cs b/EnvelopeGenerator.Domain/Entities/Signature.cs index 42f26a95..c267db0f 100644 --- a/EnvelopeGenerator.Domain/Entities/Signature.cs +++ b/EnvelopeGenerator.Domain/Entities/Signature.cs @@ -2,10 +2,11 @@ using System.ComponentModel; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; -using System.Text.Json.Serialization; #if NETFRAMEWORK using System; using System.Collections.Generic; +#elif NET +using System.Text.Json.Serialization; #endif namespace EnvelopeGenerator.Domain.Entities