refactor: remove PdfMetadata/PdfAMetadata, use result DTOs directly
PdfMetadata and PdfAMetadata were redundant intermediate classes that mirrored PdfValidationResult and PdfAValidationResult exactly. Changes: - Delete PdfMetadata.cs and PdfAMetadata.cs - IPdfProcessor.ValidateAsync now returns PdfValidationResult directly - IPdfProcessor.ValidatePdfAAsync now returns PdfAValidationResult directly - ValidatePdfQueryHandler: remove IMapper dependency, return result directly - ValidatePdfAQueryHandler: remove IMapper dependency, return result directly - MappingProfile: remove the two now-obsolete CreateMap calls - PdfValidationResult: add IsEncrypted parameter (was missing)
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
using AutoMapper;
|
||||
using DocumentService.Application.Common.DTOs;
|
||||
using DocumentService.Application.Common.Interfaces;
|
||||
using MediatR;
|
||||
@@ -18,20 +17,12 @@ public record ValidatePdfQuery : IRequest<PdfValidationResult>
|
||||
|
||||
/// <summary>
|
||||
/// Handler for ValidatePdfQuery
|
||||
/// Orchestrates PDF validation using IPdfProcessor and AutoMapper
|
||||
/// </summary>
|
||||
public class ValidatePdfQueryHandler(IPdfProcessor PdfProcessor, IMapper Mapper)
|
||||
public class ValidatePdfQueryHandler(IPdfProcessor pdfProcessor)
|
||||
: IRequestHandler<ValidatePdfQuery, PdfValidationResult>
|
||||
{
|
||||
/// <summary>
|
||||
/// Validates PDF and returns metadata
|
||||
/// </summary>
|
||||
public async Task<PdfValidationResult> Handle(ValidatePdfQuery request, CancellationToken cancellationToken)
|
||||
{
|
||||
// Call DevExpress service directly with stream (exceptions propagate naturally)
|
||||
var metadata = await PdfProcessor.ValidateAsync(request.PdfStream);
|
||||
|
||||
// Map DTO to response DTO using AutoMapper
|
||||
return Mapper.Map<PdfValidationResult>(metadata);
|
||||
return await pdfProcessor.ValidateAsync(request.PdfStream);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user