Implemented centralised audit logging
This commit is contained in:
@@ -5,16 +5,19 @@ namespace PostFundManagement.Domain.Entities;
|
||||
[EntityTypeConfiguration<AuditLogConfiguration, AuditLog>]
|
||||
public class AuditLog : Models.AuditLog
|
||||
{
|
||||
public virtual User? Performer { get; set; }
|
||||
public virtual Tenant? Tenant { get; set; }
|
||||
|
||||
public virtual User? Performer { get; set; }
|
||||
}
|
||||
|
||||
public sealed class AuditLogConfiguration : IEntityTypeConfiguration<Domain.Entities.AuditLog>
|
||||
public sealed class AuditLogConfiguration : IEntityTypeConfiguration<AuditLog>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<Domain.Entities.AuditLog> builder)
|
||||
public void Configure(EntityTypeBuilder<AuditLog> builder)
|
||||
{
|
||||
builder.ToTable(nameof(Domain.Entities.AuditLog).Pluralize());
|
||||
builder.ToTable(nameof(AuditLog).Pluralize());
|
||||
|
||||
builder.HasKey(pk => pk.Id);
|
||||
builder.Property(f => f.TenantId).IsRequired(false);
|
||||
builder.Property(f => f.EntityName).IsRequired().HasMaxLength(LabelLength);
|
||||
builder.Property(f => f.EntityId).IsRequired();
|
||||
builder.Property(f => f.Action).IsRequired().HasMaxLength(ShortLabelLength);
|
||||
@@ -22,6 +25,12 @@ public sealed class AuditLogConfiguration : IEntityTypeConfiguration<Domain.Enti
|
||||
builder.Property(f => f.PerformedBy).IsRequired();
|
||||
builder.Property(f => f.Timestamp).IsRequired().HasDefaultValueSql("now()");
|
||||
|
||||
builder.HasOne(f => f.Tenant)
|
||||
.WithMany()
|
||||
.HasForeignKey(fk => fk.TenantId)
|
||||
.IsRequired(false)
|
||||
.OnDelete(DeleteBehavior.NoAction);
|
||||
|
||||
builder.HasOne(f => f.Performer)
|
||||
.WithMany()
|
||||
.HasForeignKey(fk => fk.PerformedBy)
|
||||
|
||||
Reference in New Issue
Block a user