using LSFE.Infrastructure.Dto.Planning; using LSFE.Infrastructure.Entities; using LSFE.Infrastructure.Entities.Admin; using LSFE.Infrastructure.Entities.Auth; using LSFE.Infrastructure.Entities.Doctor; using LSFE.Infrastructure.Entities.Maintenance; using LSFE.Infrastructure.Entities.Planning; using LSFE.Infrastructure.Entities.Reports; using LSFE.Infrastructure.Entities.TimeKeeping; using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Identity.EntityFrameworkCore; using Microsoft.EntityFrameworkCore; using System; using System.Collections.Generic; using System.Data; using System.Linq; using System.Text; using System.Threading.Tasks; namespace LSFE.Infrastructure.Database { public class LSFEDbContext : IdentityDbContext { public LSFEDbContext(DbContextOptions options) : base(options) { } public DbSet Doctors { get; set; } public DbSet ForDoctorApprovals { get; set; } public DbSet Departments { get; set; } public DbSet Attachments { get; set; } public DbSet Areas { get; set; } public DbSet Districts { get; set; } public DbSet Institutions { get; set; } public DbSet Specializations { get; set; } public DbSet InstitutionCategories { get; set; } public DbSet Products { get; set; } public DbSet ProductTransactions { get; set; } public DbSet InventoryTransactions { get; set; } public DbSet Territories { get; set; } public DbSet Divisions { get; set; } public DbSet MRRawPlans { get; set; } public DbSet MRRawPlansDto { get; set; } public DbSet CatchUpCalls { get; set; } public DbSet Inventory { get; set; } public DbSet CatchUpCallReports { get; set; } public DbSet CallRateReports { get; set; } public DbSet CallReachReports { get; set; } public DbSet ActualCoverageReports { get; set; } public virtual DbSet DoctorWithPlan { get; set; } public DbSet DoctorCoverageTodays { get; set; } public virtual DbSet PendingApprovals { get; set; } public virtual DbSet DoctorByIds { get; set; } public DbSet MRPlanDetails { get; set; } public DbSet MRPlanHeaders { get; set; } public DbSet Attendances { get; set; } public virtual DbSet AttendanceDto { get; set; } public DbSet ErrorLogs { get; set; } public DbSet UserDevices { get; set; } public DbSet AuthorizeRoles { get; internal set; } protected override void OnModelCreating(ModelBuilder modelBuilder) { base.OnModelCreating(modelBuilder); modelBuilder.Entity(entity => { entity.ToTable("ActualCoverageReport"); entity.HasNoKey(); }); modelBuilder.Entity() .Property(d => d.AreaId) .ValueGeneratedOnAdd(); modelBuilder.Entity() .Property(d => d.DivisionId) .ValueGeneratedOnAdd(); modelBuilder.Entity() .HasOne(d => d.Institution) .WithMany(i => i.Doctors) .HasForeignKey(d => d.InstitutionId); modelBuilder.Entity() .HasOne(d => d.Districts) .WithMany(i => i.Doctors) .HasForeignKey(d => d.DistrictId); modelBuilder.Entity(b => { b.ToTable("Districts"); b.HasOne(u => u.Areas) .WithMany() .HasForeignKey(u => u.AreaId) .IsRequired(false); }); modelBuilder.Entity(b => { b.ToTable("Institutions"); b.HasOne(u => u.Territories) .WithMany() .HasForeignKey(u => u.TerritoryId) .IsRequired(false); }); modelBuilder.Entity(b => { b.ToTable("Territories"); b.HasOne(u => u.Districts) .WithMany() .HasForeignKey(u => u.DistrictId) .IsRequired(false); }); modelBuilder.Entity(b => { b.ToTable("Users"); b.HasOne(u => u.Attachment) .WithMany() .HasForeignKey(u => u.AttachmentId) .IsRequired(false); b.HasOne(u => u.Department) .WithMany() .HasForeignKey(u => u.DepartmentId) .IsRequired(false); }); modelBuilder.Entity(b => { b.ToTable("Attachment"); b.Property(d => d.AttachmentId) .ValueGeneratedOnAdd(); }); modelBuilder.Entity(b => { b.ToTable("Departments"); }); modelBuilder.Entity>(b => { b.ToTable("UserClaims"); }); modelBuilder.Entity>(b => { b.ToTable("UserTokens"); }); modelBuilder.Entity(b => { b.ToTable("Roles"); }); modelBuilder.Entity>(b => { b.ToTable("UserRoles"); }); } } }