using Lada.Framework.Data.Domains;
using Lada.Framework.Data.Domains.Identity;
using Lada.Framework.Data.Domains.Settings;
using Lada.Framework.Data.Mappings.EntityMappings;
using Lada.Framework.Data.Mappings.EntityMappings.Settings;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;

namespace Lada.Framework.Data.Mappings.DbContexts
{
    public partial class LadaDbContext : IdentityDbContext<User, Role, int, IdentityUserClaim<int>, UserRole, IdentityUserLogin<int>, IdentityRoleClaim<int>, IdentityUserToken<int>>
    {
        public virtual DbSet<CallPath> CallPaths { get; set; }
        public virtual DbSet<CallPathVersion> CallPathVersions { get; set; }
        public virtual DbSet<Permission> Permissions { get; set; }
        public virtual DbSet<PermissionRole> PermissionRoles { get; set; }

        public LadaDbContext(DbContextOptions<LadaDbContext> options)
            : base(options)
        {

        }


        protected override void OnModelCreating(ModelBuilder builder)
        {
            base.OnModelCreating(builder);
            builder
                .RegisterEntityMapping<AppConfig, AppConfigMap>();

            ApplyOrderMappings(builder);
            ApplyCMSMappings(builder);
            ApplyTruckMappings(builder);
            ApplyHRMappings(builder);
            ApplyMediaMappings(builder);
            ApplyFinanceMappings(builder);
            ApplyUserMappings(builder);
            ApplyCrmMappings(builder);
            ApplyAIMappings(builder);
            ApplyErrorReportMappings(builder);
            ApplyPremiseMappings(builder);
            ApplyOrderBusinessMappings(builder);
            ApplyRewardPenaltyMappings(builder);

            // Đăng ký mapping cho CallPath
            builder.RegisterEntityMapping<CallPath, CallPathMap>();
            builder.RegisterEntityMapping<CallPathVersion, CallPathVersionMap>();
        }

    }

}
