From 872f745d4592da88063ea008833220b87a16288e Mon Sep 17 00:00:00 2001 From: noremacskich Date: Fri, 11 Oct 2024 00:56:41 -0500 Subject: [PATCH] Added Audit package, and opted the expression tables in --- .../ExpressedRealms.DB.csproj | 1 + .../ExpressedRealmsDbContext.cs | 69 ++++++++++--------- .../Models/Expressions/Expression.cs | 2 + .../Models/Expressions/ExpressionSection.cs | 2 + .../Expressions/ExpressionSectionType.cs | 3 + 5 files changed, 43 insertions(+), 34 deletions(-) diff --git a/api/ExpressedRealms.DB/ExpressedRealms.DB.csproj b/api/ExpressedRealms.DB/ExpressedRealms.DB.csproj index 1b0d9408..8172f37a 100644 --- a/api/ExpressedRealms.DB/ExpressedRealms.DB.csproj +++ b/api/ExpressedRealms.DB/ExpressedRealms.DB.csproj @@ -7,6 +7,7 @@ + all diff --git a/api/ExpressedRealms.DB/ExpressedRealmsDbContext.cs b/api/ExpressedRealms.DB/ExpressedRealmsDbContext.cs index b35e48ea..650fb709 100644 --- a/api/ExpressedRealms.DB/ExpressedRealmsDbContext.cs +++ b/api/ExpressedRealms.DB/ExpressedRealmsDbContext.cs @@ -1,40 +1,42 @@ -using ExpressedRealms.DB.Characters; +using Audit.EntityFramework; +using ExpressedRealms.DB.Characters; using ExpressedRealms.DB.Models.Expressions; using ExpressedRealms.DB.Models.Skills; using ExpressedRealms.DB.Models.Statistics; using ExpressedRealms.DB.UserProfile.PlayerDBModels; using Microsoft.AspNetCore.Identity; -using Microsoft.AspNetCore.Identity.EntityFrameworkCore; using Microsoft.EntityFrameworkCore; -namespace ExpressedRealms.DB +namespace ExpressedRealms.DB; + +[AuditDbContext(Mode = AuditOptionMode.OptIn)] +public class ExpressedRealmsDbContext : AuditIdentityDbContext { - public class ExpressedRealmsDbContext : IdentityDbContext + protected override void OnModelCreating(ModelBuilder builder) { - protected override void OnModelCreating(ModelBuilder builder) - { - base.OnModelCreating(builder); - builder.ApplyConfiguration(new CharacterConfiguration()); - builder.ApplyConfiguration(new PlayerConfiguration()); - builder.ApplyConfiguration(new ExpressionConfiguration()); - builder.ApplyConfiguration(new ExpressionSectionsConfiguration()); - builder.ApplyConfiguration(new ExpressionSectionTypeConfiguration()); - builder.ApplyConfiguration(new ExpressionPublishStatusConfiguration()); - - builder.ApplyConfiguration(new StatTypeConfiguration()); - builder.ApplyConfiguration(new StatLevelConfiguration()); - builder.ApplyConfiguration(new StatDescriptionMappingConfiguration()); + base.OnModelCreating(builder); + builder.ApplyConfiguration(new CharacterConfiguration()); + builder.ApplyConfiguration(new PlayerConfiguration()); + builder.ApplyConfiguration(new ExpressionConfiguration()); + builder.ApplyConfiguration(new ExpressionSectionsConfiguration()); + builder.ApplyConfiguration(new ExpressionSectionTypeConfiguration()); + builder.ApplyConfiguration(new StatTypeConfiguration()); + builder.ApplyConfiguration(new StatLevelConfiguration()); + builder.ApplyConfiguration(new StatDescriptionMappingConfiguration()); + builder.ApplyConfiguration(new ExpressionPublishStatusConfiguration()); - builder.ApplyConfiguration(new CharacterSkillsMappingConfiguration()); - builder.ApplyConfiguration(new ModifierTypeConfiguration()); - builder.ApplyConfiguration(new SkillLevelConfiguration()); - builder.ApplyConfiguration(new SkillLevelBenefitConfiguration()); - builder.ApplyConfiguration(new SkillSubTypeConfiguration()); - builder.ApplyConfiguration(new SkillTypeConfiguration()); - } + builder.ApplyConfiguration(new CharacterSkillsMappingConfiguration()); + builder.ApplyConfiguration(new ModifierTypeConfiguration()); + builder.ApplyConfiguration(new SkillLevelConfiguration()); + builder.ApplyConfiguration(new SkillLevelBenefitConfiguration()); + builder.ApplyConfiguration(new SkillSubTypeConfiguration()); + builder.ApplyConfiguration(new SkillTypeConfiguration()); + } - public ExpressedRealmsDbContext(DbContextOptions options) - : base(options) { } + public ExpressedRealmsDbContext(DbContextOptions options) + : base(options) + { + } public DbSet Characters { get; set; } public DbSet Players { get; set; } @@ -47,11 +49,10 @@ public ExpressedRealmsDbContext(DbContextOptions optio public DbSet StatLevels { get; set; } public DbSet StatDescriptionMappings { get; set; } - public DbSet CharacterSkillsMappings { get; set; } - public DbSet ModifierTypes { get; set; } - public DbSet SkillLevels { get; set; } - public DbSet SkillLevelBenefits { get; set; } - public DbSet SkillSubTypes { get; set; } - public DbSet SkillTypes { get; set; } - } -} + public DbSet CharacterSkillsMappings { get; set; } + public DbSet ModifierTypes { get; set; } + public DbSet SkillLevels { get; set; } + public DbSet SkillLevelBenefits { get; set; } + public DbSet SkillSubTypes { get; set; } + public DbSet SkillTypes { get; set; } +} \ No newline at end of file diff --git a/api/ExpressedRealms.DB/Models/Expressions/Expression.cs b/api/ExpressedRealms.DB/Models/Expressions/Expression.cs index 1b4645ac..6218fa6b 100644 --- a/api/ExpressedRealms.DB/Models/Expressions/Expression.cs +++ b/api/ExpressedRealms.DB/Models/Expressions/Expression.cs @@ -1,8 +1,10 @@ +using Audit.EntityFramework; using ExpressedRealms.DB.Characters; using ExpressedRealms.DB.Interceptors; namespace ExpressedRealms.DB.Models.Expressions; +[AuditInclude] public class Expression : ISoftDelete { public int Id { get; set; } diff --git a/api/ExpressedRealms.DB/Models/Expressions/ExpressionSection.cs b/api/ExpressedRealms.DB/Models/Expressions/ExpressionSection.cs index cb26f582..4bd7ec13 100644 --- a/api/ExpressedRealms.DB/Models/Expressions/ExpressionSection.cs +++ b/api/ExpressedRealms.DB/Models/Expressions/ExpressionSection.cs @@ -1,7 +1,9 @@ +using Audit.EntityFramework; using ExpressedRealms.DB.Characters; namespace ExpressedRealms.DB.Models.Expressions; +[AuditInclude] public class ExpressionSection { public int Id { get; set; } diff --git a/api/ExpressedRealms.DB/Models/Expressions/ExpressionSectionType.cs b/api/ExpressedRealms.DB/Models/Expressions/ExpressionSectionType.cs index 90983258..90372138 100644 --- a/api/ExpressedRealms.DB/Models/Expressions/ExpressionSectionType.cs +++ b/api/ExpressedRealms.DB/Models/Expressions/ExpressionSectionType.cs @@ -1,5 +1,8 @@ +using Audit.EntityFramework; + namespace ExpressedRealms.DB.Models.Expressions; +[AuditInclude] public class ExpressionSectionType { public int Id { get; set; }