refactor(BurnPdfCommand): rename SourceBuffer to Document in BurnPdfCommand and handler

- Renamed parameter `SourceBuffer` to `Document` in BurnPdfCommand record
- Updated all usages of `request.SourceBuffer` to `request.Document`
- Reorganized method order for better readability (Handle moved up)
- No functional or behavioral changes introduced
This commit is contained in:
tekh 2025-11-07 14:56:34 +01:00
parent 6134b58a4c
commit defa53fa26

View File

@ -17,7 +17,7 @@ namespace EnvelopeGenerator.Application.Pdf;
/// <summary>
///
/// </summary>
public record BurnPdfCommand(byte[] SourceBuffer, List<string> InstantJSONList, int EnvelopeId) : IRequest<byte[]>;
public record BurnPdfCommand(byte[] Document, List<string> InstantJSONList, int EnvelopeId) : IRequest<byte[]>;
/// <summary>
///
@ -47,6 +47,27 @@ public class BurnPdfCommandHandler : IRequestHandler<BurnPdfCommand, byte[]>
_logger = logger;
}
/// <summary>
///
/// </summary>
/// <param name="request"></param>
/// <param name="cancel"></param>
/// <returns></returns>
/// <exception cref="NotImplementedException"></exception>
public async Task<byte[]> Handle(BurnPdfCommand request, CancellationToken cancel)
{
// 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.Document, elements)
: BurnInstantJSONAnnotsToPDF(request.Document, request.InstantJSONList);
}
private byte[] BurnElementAnnotsToPDF(byte[] pSourceBuffer, List<Signature> elements)
{
// Add background
@ -217,24 +238,4 @@ public class BurnPdfCommandHandler : IRequestHandler<BurnPdfCommand, byte[]>
}
}
}
/// <summary>
///
/// </summary>
/// <param name="request"></param>
/// <param name="cancel"></param>
/// <returns></returns>
/// <exception cref="NotImplementedException"></exception>
public async Task<byte[]> Handle(BurnPdfCommand request, CancellationToken cancel)
{
// 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);
}
}