feat: Hinzufügen von Newtonsoft.Json Unterstützung und Entfernen von doppelten Controller-Konfigurationen

- Hinzugefügt: Newtonsoft.Json zur Projektdatei und konfiguriert, um UTC für DateTime-Serialisierung zu verwenden.
- Entfernt: Doppelte Controller-Konfiguration für das Hinzufügen von Conventions.
- Aktualisiert: Projektdatei mit neuen Paketreferenzen für Newtonsoft.Json und Microsoft.AspNetCore.Mvc.NewtonsoftJson.
This commit is contained in:
Developer 02
2024-11-08 16:11:48 +01:00
parent 31c8249516
commit 7316343658
2 changed files with 13 additions and 2 deletions

View File

@@ -9,6 +9,7 @@ using DigitalData.Core.API;
using DigitalData.UserManager.API.Controllers;
using DigitalData.UserManager.Application.Services;
using Microsoft.Data.SqlClient;
using Newtonsoft.Json;
var logger = LogManager.Setup().LoadConfigurationFromAppSettings().GetCurrentClassLogger();
logger.Debug("init main");
@@ -25,8 +26,16 @@ try {
builder.Logging.ClearProviders();
builder.Host.UseNLog();
builder.Services.AddControllers();
builder.Services.AddControllers(opt =>
{
opt.Conventions.Add(new RemoveIfControllerConvention()
.AndIf(c => c.ControllerName == nameof(EncryptionController).Replace("Controller", ""))
.AndIf(c => !config.GetValue<bool>("UseEncryptor")));
}).AddNewtonsoftJson(options =>
{
options.SerializerSettings.DateTimeZoneHandling = DateTimeZoneHandling.Utc;
});
if (builder.Configuration.GetValue<bool>("UseSwagger"))
{