refactor: Update Application handlers to convert byte[] to Stream

- ValidatePdfQueryHandler: Convert byte[] → MemoryStream before calling IPdfProcessor
- ValidatePdfAQueryHandler: Same pattern
- Update AutoMapper namespace imports (remove Domain.Models.ValueObjects references)
This commit is contained in:
2026-07-20 11:55:25 +02:00
parent 1de781748b
commit e13e85182a
3 changed files with 19 additions and 6 deletions

View File

@@ -36,10 +36,13 @@ public class ValidatePdfQueryHandler(IPdfProcessor PdfProcessor, IMapper Mapper)
// Use byte[] if available, otherwise convert Base64
byte[] pdfBytes = request.PdfBytes ?? Convert.FromBase64String(request.Base64Pdf!);
// Call DevExpress service (can throw PdfProcessingException)
var metadata = await PdfProcessor.ValidateAsync(pdfBytes);
// Convert to stream for IPdfProcessor (using MemoryStream)
using var pdfStream = new MemoryStream(pdfBytes);
// Map domain entity to DTO using AutoMapper
// Call DevExpress service (exceptions propagate naturally)
var metadata = await PdfProcessor.ValidateAsync(pdfStream);
// Map DTO to response DTO using AutoMapper
return Mapper.Map<PdfValidationResult>(metadata);
}
}