feat(Format): create to centrilize the formats.
- Add json serializer settings for diagnostics and implement to DocumentController
This commit is contained in:
parent
e623680c3f
commit
fa46dd1fa8
20
EnvelopeGenerator.Domain/Constants/Format.cs
Normal file
20
EnvelopeGenerator.Domain/Constants/Format.cs
Normal file
@ -0,0 +1,20 @@
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Serialization;
|
||||
|
||||
namespace EnvelopeGenerator.Domain.Constants
|
||||
{
|
||||
public class Format
|
||||
{
|
||||
#region Json Serializer Settings
|
||||
public static class Json
|
||||
{
|
||||
public static readonly JsonSerializerSettings ForDiagnostics = new JsonSerializerSettings()
|
||||
{
|
||||
ContractResolver = new CamelCasePropertyNamesContractResolver(),
|
||||
Formatting = Formatting.Indented,
|
||||
NullValueHandling = NullValueHandling.Include
|
||||
};
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@ -35,6 +35,7 @@
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="DigitalData.EmailProfilerDispatcher.Abstraction.Attributes" Version="1.0.0" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
<PackageReference Include="UserManager.Domain" Version="3.2.3" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
@ -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
|
||||
};
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user