55 lines
1.8 KiB
C#
55 lines
1.8 KiB
C#
using GozareshgirProgramManager.Domain.ProjectAgg.Entities;
|
|
using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task.TaskSection;
|
|
using GozareshgirProgramManager.Domain.ProjectAgg.Enums;
|
|
using GozareshgirProgramManager.Infrastructure.Persistence._Common;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
|
|
|
namespace GozareshgirProgramManager.Infrastructure.Persistence.Mappings;
|
|
|
|
public class TaskSectionMapping : IEntityTypeConfiguration<TaskSection>
|
|
{
|
|
public void Configure(EntityTypeBuilder<TaskSection> builder)
|
|
{
|
|
builder.ToTable("TaskSections");
|
|
|
|
builder.HasKey(ts => ts.Id);
|
|
|
|
builder.Property(ts => ts.Id)
|
|
.ValueGeneratedNever();
|
|
|
|
builder.Property(ts => ts.TaskId)
|
|
.IsRequired();
|
|
|
|
|
|
builder.Property(ts => ts.InitialEstimatedHours)
|
|
.HasTimeSpanConversion();
|
|
|
|
builder.Property(ts => ts.Status)
|
|
.HasConversion<string>()
|
|
.HasMaxLength(50)
|
|
.IsRequired();
|
|
|
|
builder.Property(x=>x.InitialDescription)
|
|
.HasMaxLength(500)
|
|
.IsRequired(false);
|
|
|
|
builder.Property(ts => ts.CurrentAssignedUserId);
|
|
|
|
// Navigation to ProjectTask (Task level)
|
|
builder.HasOne(ts => ts.Task)
|
|
.WithMany(t => t.Sections)
|
|
.HasForeignKey(ts => ts.TaskId)
|
|
.OnDelete(DeleteBehavior.Cascade);
|
|
|
|
builder.HasMany(ts => ts.Activities)
|
|
.WithOne(a => a.Section)
|
|
.HasForeignKey(a => a.SectionId)
|
|
.OnDelete(DeleteBehavior.Cascade);
|
|
|
|
builder.HasOne(x => x.Skill)
|
|
.WithMany(y => y.Sections).HasForeignKey(y => y.SkillId)
|
|
.OnDelete(DeleteBehavior.Cascade);
|
|
}
|
|
}
|