diff --git a/EnvelopeGenerator.Application/Pdf/BurnPdfCommand.cs b/EnvelopeGenerator.Application/Pdf/BurnPdfCommand.cs index ca562fd2..97e1d783 100644 --- a/EnvelopeGenerator.Application/Pdf/BurnPdfCommand.cs +++ b/EnvelopeGenerator.Application/Pdf/BurnPdfCommand.cs @@ -1,6 +1,10 @@ -using EnvelopeGenerator.Application.Common.Configurations; +using DigitalData.Core.Abstraction.Application.Repository; +using DigitalData.Core.Abstractions; +using EnvelopeGenerator.Application.Common.Configurations; +using EnvelopeGenerator.Domain.Entities; using GdPicture14; using MediatR; +using Microsoft.EntityFrameworkCore; namespace EnvelopeGenerator.Application.Pdf; @@ -23,15 +27,54 @@ public class BurnPdfCommandHandler : IRequestHandler private readonly AnnotationManager _manager; + private readonly IRepository _signRepo; + /// /// /// /// /// - public BurnPdfCommandHandler(PDFBurnerParams pdfBurnerParams, AnnotationManager manager) + /// + public BurnPdfCommandHandler(PDFBurnerParams pdfBurnerParams, AnnotationManager manager, IRepository signRepo) { _pdfBurnerParams = pdfBurnerParams; _manager = manager; + _signRepo = signRepo; + } + + 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); + } + + /// + /// + /// + /// + /// + /// + public byte[] BurnElementAnnotsToPDF(byte[] pSourceBuffer, List elements) + { + return Enumerable.Empty().ToArray(); + } + + /// + /// + /// + /// + /// + /// + public byte[] BurnInstantJSONAnnotsToPDF(byte[] pSourceBuffer, List pInstantJSONList) + { + return Enumerable.Empty().ToArray(); } ///