feat(Format): create to centrilize the formats.
- Add json serializer settings for diagnostics and implement to DocumentController
This commit is contained in:
@@ -1,15 +1,14 @@
|
||||
using DigitalData.Core.Exceptions;
|
||||
using EnvelopeGenerator.Application.EnvelopeReceivers.Queries;
|
||||
using EnvelopeGenerator.Web.Services;
|
||||
using EnvelopeGenerator.Domain.Constants;
|
||||
using MediatR;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Serialization;
|
||||
|
||||
namespace EnvelopeGenerator.Web.Controllers;
|
||||
|
||||
[Authorize(Roles = Domain.Constants.ReceiverRole.FullyAuth)]
|
||||
[Authorize(Roles = ReceiverRole.FullyAuth)]
|
||||
[ApiController]
|
||||
[Route("api/[controller]")]
|
||||
public class DocumentController : ControllerBase
|
||||
@@ -34,17 +33,10 @@ public class DocumentController : ControllerBase
|
||||
if(byteData is null || byteData.Length == 0)
|
||||
{
|
||||
_logger.LogError("Document byte data is null or empty for envelope-receiver entity:\n{envelopeKey}.",
|
||||
JsonConvert.SerializeObject(envRcv, JsonFormattingForDiagnostics));
|
||||
JsonConvert.SerializeObject(envRcv, Format.Json.ForDiagnostics));
|
||||
throw new NotFoundException("Document is empty.");
|
||||
}
|
||||
|
||||
return File(byteData, "application/octet-stream");
|
||||
}
|
||||
|
||||
private static readonly JsonSerializerSettings JsonFormattingForDiagnostics = new()
|
||||
{
|
||||
ContractResolver = new CamelCasePropertyNamesContractResolver(),
|
||||
Formatting = Formatting.Indented,
|
||||
NullValueHandling = NullValueHandling.Include
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user