mirror of
https://github.com/Sea-Haven-Industries/proposal-system.git
synced 2026-09-30 05:23:14 +00:00
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:
parent
686b42330c
commit
f44caba906
3 changed files with 10 additions and 2 deletions
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"sdk": {
|
||||
"version": "8.0.400",
|
||||
"version": "8.0.100",
|
||||
"rollForward": "latestFeature"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue