refactor(Pdf\Behaviors): Handle the history recording process in another behavior named CreateHistoryBehavior

This commit is contained in:
2025-11-12 11:00:24 +01:00
parent 380b141738
commit d88ed324be
3 changed files with 51 additions and 13 deletions

View File

@@ -1,6 +1,4 @@
using MediatR;
using EnvelopeGenerator.Application.Histories.Commands;
using EnvelopeGenerator.Domain.Constants;
using EnvelopeGenerator.Application.EnvelopeReports;
using EnvelopeGenerator.Application.Exceptions;
using EnvelopeGenerator.Domain.Entities;
@@ -40,17 +38,9 @@ public class AddReportBehavior : IPipelineBehavior<BurnPdfCommand, byte[]>
{
var docResult = await next(cancel);
if (!request.Debug)
await _sender.Send(new CreateHistoryCommand()
{
EnvelopeId = request.EnvelopeId,
UserReference = "System",
Status = EnvelopeStatus.EnvelopeReportCreated,
}, cancel);
var report = await CreateReport(request.Envelope!, cancel);
docResult = await CreateReport(request.Envelope!, cancel);
var base64 = Convert.ToBase64String(docResult);
var reportBase64 = Convert.ToBase64String(report);
return docResult;
}
@@ -71,7 +61,7 @@ public class AddReportBehavior : IPipelineBehavior<BurnPdfCommand, byte[]>
throw new CreateReportException("No report data found!");
}
var oBuffer = AddReportBehavior.DoCreateReport(oItems);
var oBuffer = DoCreateReport(oItems);
return oBuffer;
}