Files
Backend-Api/ProgramManager/src/Infrastructure/GozareshgirProgramManager.Infrastructure/Persistence/Context/ProgramManagerDbContext.cs

58 lines
2.3 KiB
C#

using GozareshgirProgramManager.Application._Common.Interfaces;
using GozareshgirProgramManager.Domain.CheckoutAgg.Entities;
using GozareshgirProgramManager.Domain.CustomerAgg;
using GozareshgirProgramManager.Application._Common.Interfaces;
using GozareshgirProgramManager.Domain.CustomerAgg;
using GozareshgirProgramManager.Domain.ProjectAgg.Entities;
using GozareshgirProgramManager.Domain.RoleAgg.Entities;
using GozareshgirProgramManager.Domain.RoleUserAgg;
using GozareshgirProgramManager.Domain.SalaryPaymentSettingAgg.Entities;
using GozareshgirProgramManager.Domain.UserAgg.Entities;
using GozareshgirProgramManager.Domain.SkillAgg.Entities;
using Microsoft.EntityFrameworkCore;
namespace GozareshgirProgramManager.Infrastructure.Persistence.Context;
public class ProgramManagerDbContext : DbContext, IProgramManagerDbContext
{
public ProgramManagerDbContext(DbContextOptions<ProgramManagerDbContext> options) : base(options)
{
}
public DbSet<Customer> Customers { get; set; } = null!;
public DbSet<TaskSection> TaskSections { get; set; } = null!;
public DbSet<ProjectSection> ProjectSections { get; set; } = null!;
public DbSet<PhaseSection> PhaseSections { get; set; } = null!;
// New Hierarchy entities
public DbSet<Project> Projects { get; set; } = null!;
public DbSet<ProjectPhase> ProjectPhases { get; set; } = null!;
public DbSet<ProjectTask> ProjectTasks { get; set; } = null!;
public DbSet<TaskSectionActivity> TaskSectionActivities { get; set; } = null!;
public DbSet<TaskSectionAdditionalTime> TaskSectionAdditionalTimes { get; set; } = null!;
public DbSet<Checkout> Checkouts { get; set; } = null!;
public DbSet<SalaryPaymentSetting?> SalaryPaymentSettings { get; set; } = null!;
public DbSet<Skill> Skills { get; set; } = null!;
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.ApplyConfigurationsFromAssembly(typeof(ProgramManagerDbContext).Assembly);
base.OnModelCreating(modelBuilder);
}
public async Task SeedSkillsIfEmptyAsync()
{
if (!Skills.Any())
{
Skills.AddRange(
new Skill("UI/UX Design"),
new Skill("Frontend"),
new Skill("Backend")
);
await SaveChangesAsync();
}
}
}