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:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user