refactor(BurnPdfCommand): replace manual JSON serialization with ToJson extension
- Replaced `System.Text.Json.JsonSerializer.Serialize(request, Format.Json.ForDiagnostics)` with `request.ToJson(Format.Json.ForDiagnostics)` for better readability and consistency. - No functional changes, purely a code style and maintainability improvement.
This commit is contained in:
parent
b8a2ad97ef
commit
f8369e350f
@ -71,15 +71,15 @@ public class BurnPdfCommandHandler : IRequestHandler<BurnPdfCommand, byte[]>
|
|||||||
.Include(env => env.Documents!).ThenInclude(doc => doc.Elements!).ThenInclude(element => element.Annotations)
|
.Include(env => env.Documents!).ThenInclude(doc => doc.Elements!).ThenInclude(element => element.Annotations)
|
||||||
.FirstOrDefaultAsync(cancel)
|
.FirstOrDefaultAsync(cancel)
|
||||||
?? throw new BadRequestException($"Envelope could not be found. Request details:\n" +
|
?? throw new BadRequestException($"Envelope could not be found. Request details:\n" +
|
||||||
System.Text.Json.JsonSerializer.Serialize(request, Format.Json.ForDiagnostics));
|
request.ToJson(Format.Json.ForDiagnostics));
|
||||||
|
|
||||||
var doc = envelope.Documents?.FirstOrDefault()
|
var doc = envelope.Documents?.FirstOrDefault()
|
||||||
?? throw new NotFoundException($"Document could not be located within the specified envelope. Request details:\n" +
|
?? throw new NotFoundException($"Document could not be located within the specified envelope. Request details:\n" +
|
||||||
System.Text.Json.JsonSerializer.Serialize(request, Format.Json.ForDiagnostics));
|
request.ToJson(Format.Json.ForDiagnostics));
|
||||||
|
|
||||||
if (doc.ByteData is null)
|
if (doc.ByteData is null)
|
||||||
throw new InvalidOperationException($"Document byte data is missing, indicating a potential data integrity issue. Request details:\n" +
|
throw new InvalidOperationException($"Document byte data is missing, indicating a potential data integrity issue. Request details:\n" +
|
||||||
System.Text.Json.JsonSerializer.Serialize(request, Format.Json.ForDiagnostics));
|
request.ToJson(Format.Json.ForDiagnostics));
|
||||||
|
|
||||||
return doc.Elements?.SelectMany(e => e.Annotations ?? Enumerable.Empty<ElementAnnotation>()).Where(annot => annot is not null).Any() ?? false
|
return doc.Elements?.SelectMany(e => e.Annotations ?? Enumerable.Empty<ElementAnnotation>()).Where(annot => annot is not null).Any() ?? false
|
||||||
? BurnElementAnnotsToPDF(doc.ByteData, doc.Elements)
|
? BurnElementAnnotsToPDF(doc.ByteData, doc.Elements)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user