Security #1
@@ -0,0 +1,23 @@
|
|||||||
|
namespace PostFundManagement.Domain.Configuration;
|
||||||
|
|
||||||
|
public sealed class AuditLog : IEntityTypeConfiguration<Entities.AuditLog>
|
||||||
|
{
|
||||||
|
public void Configure(EntityTypeBuilder<Entities.AuditLog> builder)
|
||||||
|
{
|
||||||
|
builder.ToTable(nameof(Entities.AuditLog).Pluralize());
|
||||||
|
|
||||||
|
builder.HasKey(pk => pk.Id);
|
||||||
|
builder.Property(f => f.EntityName).IsRequired().HasMaxLength(128);
|
||||||
|
builder.Property(f => f.EntityId).IsRequired();
|
||||||
|
builder.Property(f => f.Action).IsRequired().HasMaxLength(64);
|
||||||
|
builder.Property(f => f.Changes).IsRequired(false).HasColumnType("jsonb");
|
||||||
|
builder.Property(f => f.PerformedBy).IsRequired();
|
||||||
|
builder.Property(f => f.Timestamp).IsRequired().HasDefaultValueSql("now()");
|
||||||
|
|
||||||
|
builder.HasOne(f => f.Performer)
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey(fk => fk.PerformedBy)
|
||||||
|
.IsRequired()
|
||||||
|
.OnDelete(DeleteBehavior.Restrict);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
namespace PostFundManagement.Domain.Entities;
|
||||||
|
|
||||||
|
[EntityTypeConfiguration<Configuration.AuditLog, AuditLog>]
|
||||||
|
public class AuditLog : Models.AuditLog
|
||||||
|
{
|
||||||
|
public virtual User? Performer { get; set; }
|
||||||
|
}
|
||||||
@@ -4,6 +4,8 @@ namespace PostFundManagement.Infrastructure.Database;
|
|||||||
|
|
||||||
public sealed class ApplicationDbContext(DbContextOptions<ApplicationDbContext> options) : DbContext(options)
|
public sealed class ApplicationDbContext(DbContextOptions<ApplicationDbContext> options) : DbContext(options)
|
||||||
{
|
{
|
||||||
|
public DbSet<AuditLog> AuditLogs => Set<AuditLog>();
|
||||||
|
|
||||||
public DbSet<SiteVisit> SiteVisits => Set<SiteVisit>();
|
public DbSet<SiteVisit> SiteVisits => Set<SiteVisit>();
|
||||||
|
|
||||||
public DbSet<ChangeRequest> ChangeRequests => Set<ChangeRequest>();
|
public DbSet<ChangeRequest> ChangeRequests => Set<ChangeRequest>();
|
||||||
|
|||||||
Reference in New Issue
Block a user