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

71 lines
2.8 KiB
C#
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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.FileManagementAgg.Entities;
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 GozareshgirProgramManager.Domain.TaskChatAgg.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<User> Users { get; set; } = null!;
public DbSet<UserRefreshToken> RefreshTokens { get; set; } = null!;
public DbSet<Checkout> Checkouts { get; set; } = null!;
public DbSet<SalaryPaymentSetting?> SalaryPaymentSettings { get; set; } = null!;
public DbSet<Role> Roles { get; set; } = null!;
public DbSet<Skill> Skills { get; set; } = null!;
// File Management
public DbSet<UploadedFile> UploadedFiles { get; set; } = null!;
// Task Chat
public DbSet<TaskChatMessage> TaskChatMessages { 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();
}
}
}