using FJPSite.Data.Authorisation;
using FJPSite.Data.Identity;
using FJPSite.Factories;
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;

namespace FJPSite.Data;

public class ApplicationDbContext(DbContextOptions<ApplicationDbContext> options) : IdentityDbContext<UserEntity, RoleEntity, string>(options)
{
    public DbSet<Feature> Features { get; set; }
    public DbSet<FeatureAction> FeatureActions { get; set; }
    public DbSet<Module> Modules { get; set; }
    public DbSet<ModuleFeature> ModuleFeatures { get; set; }
    public DbSet<PermissionAction> Actions { get; set; }
    public DbSet<RolePermission> RolePermissions { get; set; }
    public DbSet<UserPermission> UserPermissions { get; set; }
    protected override void OnModelCreating(ModelBuilder builder)
    {
        base.OnModelCreating(builder);
    }

    protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
    {
        optionsBuilder.UseSeeding((context, _) =>
        {
            DbSeederFactory.SeedDatabase(this);
            context.SaveChanges();
        });
    }
}

