Skip to content

Commit

Permalink
Added Audit package, and opted the expression tables in
Browse files Browse the repository at this point in the history
  • Loading branch information
noremacskich committed Oct 13, 2024
1 parent 0ef3e74 commit 872f745
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 34 deletions.
1 change: 1 addition & 0 deletions api/ExpressedRealms.DB/ExpressedRealms.DB.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Audit.EntityFramework.Identity.Core" Version="27.0.3" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="8.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.0">
<PrivateAssets>all</PrivateAssets>
Expand Down
69 changes: 35 additions & 34 deletions api/ExpressedRealms.DB/ExpressedRealmsDbContext.cs
Original file line number Diff line number Diff line change
@@ -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<IdentityUser>
{
public class ExpressedRealmsDbContext : IdentityDbContext<IdentityUser>
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<ExpressedRealmsDbContext> options)
: base(options) { }
public ExpressedRealmsDbContext(DbContextOptions<ExpressedRealmsDbContext> options)
: base(options)
{
}

public DbSet<Character> Characters { get; set; }
public DbSet<Player> Players { get; set; }
Expand All @@ -47,11 +49,10 @@ public ExpressedRealmsDbContext(DbContextOptions<ExpressedRealmsDbContext> optio
public DbSet<StatLevel> StatLevels { get; set; }
public DbSet<StatDescriptionMapping> StatDescriptionMappings { get; set; }

public DbSet<CharacterSkillsMapping> CharacterSkillsMappings { get; set; }
public DbSet<ModifierType> ModifierTypes { get; set; }
public DbSet<SkillLevel> SkillLevels { get; set; }
public DbSet<SkillLevelBenefit> SkillLevelBenefits { get; set; }
public DbSet<SkillSubType> SkillSubTypes { get; set; }
public DbSet<SkillType> SkillTypes { get; set; }
}
}
public DbSet<CharacterSkillsMapping> CharacterSkillsMappings { get; set; }
public DbSet<ModifierType> ModifierTypes { get; set; }
public DbSet<SkillLevel> SkillLevels { get; set; }
public DbSet<SkillLevelBenefit> SkillLevelBenefits { get; set; }
public DbSet<SkillSubType> SkillSubTypes { get; set; }
public DbSet<SkillType> SkillTypes { get; set; }
}
2 changes: 2 additions & 0 deletions api/ExpressedRealms.DB/Models/Expressions/Expression.cs
Original file line number Diff line number Diff line change
@@ -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; }
Expand Down
Original file line number Diff line number Diff line change
@@ -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; }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
using Audit.EntityFramework;

namespace ExpressedRealms.DB.Models.Expressions;

[AuditInclude]
public class ExpressionSectionType
{
public int Id { get; set; }
Expand Down

0 comments on commit 872f745

Please sign in to comment.