feat(AddReportBehavior): add report creation logic to AddReportBehavior

- Added CreateReport method to generate PDF report from envelope data
- Integrated call to CreateReport within pipeline after history creation
- Introduced error handling via CreateReportException for missing report data
- Added necessary using directives for EnvelopeReports, Exceptions, and Entities
This commit is contained in:
Developer 02
2025-11-11 21:19:21 +01:00
parent 6f9b5d4b13
commit 292b6b2ccf
2 changed files with 31 additions and 3 deletions

View File

@@ -1,6 +1,9 @@
using MediatR;
using EnvelopeGenerator.Application.Histories.Commands;
using EnvelopeGenerator.Domain.Constants;
using EnvelopeGenerator.Application.EnvelopeReports;
using EnvelopeGenerator.Application.Exceptions;
using EnvelopeGenerator.Domain.Entities;
namespace EnvelopeGenerator.Application.Pdf.Behaviors;
@@ -40,6 +43,29 @@ public class AddReportBehavior : IPipelineBehavior<BurnPdfCommand, byte[]>
Status = EnvelopeStatus.EnvelopeReportCreated,
}, cancel);
docResult = await CreateReport(request.Envelope!, cancel);
return docResult;
}
/// <summary>
///
/// </summary>
/// <param name="envelope"></param>
/// <param name="cancel"></param>
/// <returns></returns>
/// <exception cref="CreateReportException"></exception>
public async Task<byte[]> CreateReport(Envelope envelope, CancellationToken cancel)
{
var oItems = await _sender.ReadEnvelopeReportAsync(envelope.Id, cancel: cancel);
if (!oItems.Any())
{
throw new CreateReportException("No report data found!");
}
var oBuffer = DoCreateReport(oItems);
return oBuffer;
}
}