Fix JSON enum serialization and audit log jsonb format

Add JsonStringEnumConverter so string enum values (ServiceCategory,
Priority, PricingMode, LineItemSource) deserialize correctly from
frontend requests. Wrap AuditService detail strings in a JSON object
to satisfy the Postgres jsonb column type. Relax global.json SDK
version to match installed 8.0.1xx feature band.
This commit is contained in:
Adam Moussa 2026-05-20 17:23:55 -04:00
parent 686b42330c
commit f44caba906
3 changed files with 10 additions and 2 deletions

View file

@ -1,6 +1,6 @@
{
"sdk": {
"version": "8.0.400",
"version": "8.0.100",
"rollForward": "latestFeature"
}
}

View file

@ -137,6 +137,9 @@ builder.Services.AddValidatorsFromAssemblyContaining<CreateProposalValidator>();
builder.Services.AddControllers(options =>
{
options.Filters.Add<ValidationFilter>();
}).AddJsonOptions(options =>
{
options.JsonSerializerOptions.Converters.Add(new System.Text.Json.Serialization.JsonStringEnumConverter());
});
// Middleware

View file

@ -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,
};