Files
Backend-Api/CompanyManagment.EFCore/Mapping/EmployeeMapping.cs
2025-05-01 15:01:36 +03:30

99 lines
3.9 KiB
C#

using Company.Domain.EmployeeAgg;
using Company.Domain.InsuranceEmployeeInfoAgg;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace CompanyManagment.EFCore.Mapping;
public class EmployeeMapping : IEntityTypeConfiguration<Employee>
{
public void Configure(EntityTypeBuilder<Employee> builder)
{
builder.ToTable("Employees");
builder.HasKey(x => x.id);
builder.Property(x => x.FName).HasMaxLength(255).IsRequired();
builder.Property(x => x.LName).HasMaxLength(255).IsRequired();
builder.Property(x => x.Gender).HasMaxLength(10);
builder.Property(x => x.NationalCode).HasMaxLength(10);
builder.Property(x => x.IdNumber).HasMaxLength(20);
builder.Property(x => x.Nationality).HasMaxLength(50);
builder.Property(x => x.FatherName).HasMaxLength(255);
builder.Property(x => x.DateOfBirth);
builder.Property(x => x.DateOfIssue);
builder.Property(x => x.PlaceOfIssue).HasMaxLength(50);
builder.Property(x => x.Address).HasMaxLength(500);
builder.Property(x => x.State).HasMaxLength(100);
builder.Property(x => x.City).HasMaxLength(100);
builder.Property(x => x.Phone).HasMaxLength(50);
builder.Property(x => x.IsActiveString).HasMaxLength(10);
builder.Property(x => x.MaritalStatus).HasMaxLength(10);
builder.Property(x => x.MilitaryService).HasMaxLength(100);
builder.Property(x => x.LevelOfEducation).HasMaxLength(100);
builder.Property(x => x.FieldOfStudy).HasMaxLength(255);
builder.Property(x => x.BankCardNumber).HasMaxLength(50);
builder.Property(x => x.BankBranch).HasMaxLength(100);
builder.Property(x => x.InsuranceCode).HasMaxLength(10);
builder.Property(x => x.InsuranceHistoryByYear).HasMaxLength(10);
builder.Property(x => x.InsuranceHistoryByMonth).HasMaxLength(10);
builder.Property(x => x.NumberOfChildren).HasMaxLength(10);
builder.Property(x => x.OfficePhone).HasMaxLength(50);
builder.Property(x => x.MclsUserName).HasMaxLength(100);
builder.Property(x => x.MclsPassword).HasMaxLength(100);
builder.Property(x => x.EserviceUserName).HasMaxLength(100);
builder.Property(x => x.EservicePassword).HasMaxLength(100);
builder.Property(x => x.TaxOfficeUserName).HasMaxLength(100);
builder.Property(x => x.TaxOfficepassword).HasMaxLength(100);
builder.Property(x => x.SanaUserName).HasMaxLength(100);
builder.Property(x => x.SanaPassword).HasMaxLength(100);
builder.HasMany(x => x.EmployeeChildrenList)
.WithOne(x => x.Employee)
.HasForeignKey(x => x.EmployeeId);
builder.HasMany(x => x.Contracts)
.WithOne(x => x.Employee)
.HasForeignKey(x => x.EmployeeId);
builder.HasMany(x => x.LeftWorks)
.WithOne(x => x.Employee)
.HasForeignKey(x => x.EmployeeId);
builder.HasOne(x => x.InsuranceEmployeeInfo)
.WithOne(x => x.Employee)
.HasForeignKey<InsuranceEmployeeInfo>(x => x.EmployeeId);
builder.HasMany(x => x.PersonnelCodeList)
.WithOne(x => x.Employee)
.HasForeignKey(x => x.EmployeeId);
builder.HasMany(x => x.CustomizeCheckouts)
.WithOne(x => x.Employee)
.HasForeignKey(x => x.EmployeeId);
#region Pooya
builder.HasMany(x => x.EmployeeDocuments)
.WithOne(x => x.Employee)
.HasForeignKey(x => x.EmployeeId);
builder.HasMany(x => x.EmployeeBankInformationList).WithOne(x => x.Employee)
.HasForeignKey(x => x.EmployeeId);
builder.Ignore(x => x.FullName);
#endregion
#region Mahan
builder.Property(x => x.IdNumberSerial).HasMaxLength(25);
builder.Property(x => x.IdNumberSeri).HasMaxLength(25);
#endregion
}
}