using Indotalent.Data.Entities; using Indotalent.Shared.Consts; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; namespace Indotalent.Infrastructure.Database.MsSQL.Configuration; public class TransferConfiguration : IEntityTypeConfiguration { public void Configure(EntityTypeBuilder builder) { builder.Property(t => t.AutoNumber).HasMaxLength(GlobalConsts.StringLengthShort); builder.Property(t => t.EmployeeId).HasMaxLength(GlobalConsts.StringLengthId); builder.Property(t => t.FromBranchId).HasMaxLength(GlobalConsts.StringLengthId); builder.Property(t => t.FromDepartmentId).HasMaxLength(GlobalConsts.StringLengthId); builder.Property(t => t.FromDesignationId).HasMaxLength(GlobalConsts.StringLengthId); builder.Property(t => t.ToBranchId).HasMaxLength(GlobalConsts.StringLengthId); builder.Property(t => t.ToDepartmentId).HasMaxLength(GlobalConsts.StringLengthId); builder.Property(t => t.ToDesignationId).HasMaxLength(GlobalConsts.StringLengthId); builder.Property(t => t.TransferNote).HasMaxLength(GlobalConsts.StringLengthMedium); builder.Property(t => t.Status).HasMaxLength(GlobalConsts.StringLengthShort); builder.HasIndex(e => new { e.TenantId, e.AutoNumber }).IsUnique(); builder.HasIndex(t => t.EmployeeId); builder.HasOne(t => t.Employee).WithMany().HasForeignKey(t => t.EmployeeId).OnDelete(DeleteBehavior.NoAction); builder.HasOne(t => t.FromBranch).WithMany().HasForeignKey(t => t.FromBranchId).OnDelete(DeleteBehavior.NoAction); builder.HasOne(t => t.FromDepartment).WithMany().HasForeignKey(t => t.FromDepartmentId).OnDelete(DeleteBehavior.NoAction); builder.HasOne(t => t.FromDesignation).WithMany().HasForeignKey(t => t.FromDesignationId).OnDelete(DeleteBehavior.NoAction); builder.HasOne(t => t.ToBranch).WithMany().HasForeignKey(t => t.ToBranchId).OnDelete(DeleteBehavior.NoAction); builder.HasOne(t => t.ToDepartment).WithMany().HasForeignKey(t => t.ToDepartmentId).OnDelete(DeleteBehavior.NoAction); builder.HasOne(t => t.ToDesignation).WithMany().HasForeignKey(t => t.ToDesignationId).OnDelete(DeleteBehavior.NoAction); } }