diff --git a/api/global.json b/api/global.json index ae9f38c..391ba3c 100644 --- a/api/global.json +++ b/api/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "8.0.400", + "version": "8.0.100", "rollForward": "latestFeature" } } diff --git a/api/src/ProposalSystem.Api/Program.cs b/api/src/ProposalSystem.Api/Program.cs index b3ac383..088f998 100644 --- a/api/src/ProposalSystem.Api/Program.cs +++ b/api/src/ProposalSystem.Api/Program.cs @@ -137,6 +137,9 @@ builder.Services.AddValidatorsFromAssemblyContaining(); builder.Services.AddControllers(options => { options.Filters.Add(); +}).AddJsonOptions(options => +{ + options.JsonSerializerOptions.Converters.Add(new System.Text.Json.Serialization.JsonStringEnumConverter()); }); // Middleware diff --git a/api/src/ProposalSystem.Infrastructure/Services/AuditService.cs b/api/src/ProposalSystem.Infrastructure/Services/AuditService.cs index 9909d9a..355fea8 100644 --- a/api/src/ProposalSystem.Infrastructure/Services/AuditService.cs +++ b/api/src/ProposalSystem.Infrastructure/Services/AuditService.cs @@ -1,3 +1,4 @@ +using System.Text.Json; using ProposalSystem.Application.Interfaces; using ProposalSystem.Domain.Entities; using ProposalSystem.Infrastructure.Data; @@ -17,13 +18,17 @@ public class AuditService : IAuditService public async Task LogAsync(AuditAction action, Guid? proposalId, string? details = null, CancellationToken ct = default) { + var jsonDetails = details != null + ? JsonSerializer.Serialize(new { message = details }) + : null; + var entry = new AuditLog { Id = Guid.NewGuid(), ProposalId = proposalId, UserId = _currentUser.UserId, Action = action, - Details = details, + Details = jsonDetails, Timestamp = DateTime.UtcNow, IpAddress = _currentUser.IpAddress, };