69 lines
2.0 KiB
C#
69 lines
2.0 KiB
C#
using GozareshgirProgramManager.Domain.ProjectAgg.Entities;
|
|
using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Phase;
|
|
using GozareshgirProgramManager.Domain.ProjectAgg.Enums;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
|
|
|
namespace GozareshgirProgramManager.Infrastructure.Persistence.Mappings;
|
|
|
|
public class ProjectPhaseMapping : IEntityTypeConfiguration<ProjectPhase>
|
|
{
|
|
public void Configure(EntityTypeBuilder<ProjectPhase> builder)
|
|
{
|
|
builder.ToTable("ProjectPhases");
|
|
|
|
builder.HasKey(ph => ph.Id);
|
|
|
|
builder.Property(ph => ph.Id)
|
|
.ValueGeneratedNever();
|
|
|
|
builder.Property(ph => ph.Name)
|
|
.HasMaxLength(200)
|
|
.IsRequired();
|
|
|
|
builder.Property(ph => ph.Description)
|
|
.HasMaxLength(1000)
|
|
.IsRequired(false);
|
|
|
|
builder.Property(ph => ph.CreationDate)
|
|
.IsRequired();
|
|
|
|
builder.Property(ph => ph.ProjectId)
|
|
.IsRequired();
|
|
|
|
builder.Property(ph => ph.Status)
|
|
.HasConversion<string>()
|
|
.HasMaxLength(50)
|
|
.IsRequired();
|
|
|
|
builder.Property(ph => ph.StartDate)
|
|
.IsRequired(false);
|
|
|
|
builder.Property(ph => ph.EndDate)
|
|
.IsRequired(false);
|
|
|
|
builder.Property(ph => ph.OrderIndex)
|
|
.IsRequired();
|
|
|
|
|
|
builder.Property(ph => ph.HasAssignmentOverride)
|
|
.IsRequired();
|
|
|
|
builder.Property(x => x.DeployStatus)
|
|
.HasConversion<string>().HasMaxLength(30);
|
|
|
|
// Relationship with Project
|
|
builder.HasOne(ph => ph.Project)
|
|
.WithMany(p => p.Phases)
|
|
.HasForeignKey(ph => ph.ProjectId)
|
|
.OnDelete(DeleteBehavior.Cascade);
|
|
|
|
// One-to-many relationship with ProjectTasks
|
|
builder.HasMany(ph => ph.Tasks)
|
|
.WithOne(t => t.Phase)
|
|
.HasForeignKey(t => t.PhaseId)
|
|
.OnDelete(DeleteBehavior.Cascade);
|
|
|
|
}
|
|
}
|