71 lines
2.8 KiB
C#
71 lines
2.8 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.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();
|
||
}
|
||
}
|
||
}
|