using Indotalent.Data.Entities; using Indotalent.Shared.Consts; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; namespace Indotalent.Infrastructure.Database.MsSQL.Configuration; public class EmployeeConfiguration : IEntityTypeConfiguration { public void Configure(EntityTypeBuilder builder) { builder.Property(e => e.AutoNumber) .HasMaxLength(GlobalConsts.StringLengthShort); builder.Property(e => e.Code) .HasMaxLength(GlobalConsts.StringLengthShort); builder.Property(e => e.FirstName) .HasMaxLength(GlobalConsts.StringLengthShort); builder.Property(e => e.MiddleName) .HasMaxLength(GlobalConsts.StringLengthShort); builder.Property(e => e.LastName) .HasMaxLength(GlobalConsts.StringLengthShort); builder.Property(e => e.JobDescription) .HasMaxLength(GlobalConsts.StringLengthMedium); builder.Property(e => e.GradeId) .HasMaxLength(GlobalConsts.StringLengthId); builder.Property(e => e.BranchId) .HasMaxLength(GlobalConsts.StringLengthId); builder.Property(e => e.DepartmentId) .HasMaxLength(GlobalConsts.StringLengthId); builder.Property(e => e.DesignationId) .HasMaxLength(GlobalConsts.StringLengthId); builder.Property(e => e.BasicSalary) .HasColumnType("decimal(18,2)"); builder.Property(e => e.SalaryBankName) .HasMaxLength(GlobalConsts.StringLengthShort); builder.Property(e => e.SalaryBankAccountName) .HasMaxLength(GlobalConsts.StringLengthShort); builder.Property(e => e.SalaryBankAccountNumber) .HasMaxLength(GlobalConsts.StringLengthShort); builder.Property(e => e.PlaceOfBirth) .HasMaxLength(GlobalConsts.StringLengthShort); builder.Property(e => e.Gender) .HasMaxLength(GlobalConsts.StringLengthShort); builder.Property(e => e.MaritalStatus) .HasMaxLength(GlobalConsts.StringLengthShort); builder.Property(e => e.Religion) .HasMaxLength(GlobalConsts.StringLengthShort); builder.Property(e => e.BloodType) .HasMaxLength(GlobalConsts.StringLengthShort); builder.Property(e => e.IdentityNumber) .HasMaxLength(GlobalConsts.StringLengthShort); builder.Property(e => e.TaxNumber) .HasMaxLength(GlobalConsts.StringLengthShort); builder.Property(e => e.LastEducation) .HasMaxLength(GlobalConsts.StringLengthShort); builder.Property(e => e.EmployeeStatus) .HasMaxLength(GlobalConsts.StringLengthShort); builder.Property(e => e.EmploymentType) .HasMaxLength(GlobalConsts.StringLengthShort); builder.Property(e => e.StreetAddress) .HasMaxLength(GlobalConsts.StringLengthShort); builder.Property(e => e.City) .HasMaxLength(GlobalConsts.StringLengthShort); builder.Property(e => e.StateProvince) .HasMaxLength(GlobalConsts.StringLengthShort); builder.Property(e => e.ZipCode) .HasMaxLength(GlobalConsts.StringLengthShort); builder.Property(e => e.Phone) .HasMaxLength(GlobalConsts.StringLengthShort); builder.Property(e => e.Email) .HasMaxLength(GlobalConsts.StringLengthShort); builder.Property(e => e.SocialMediaLinkedIn) .HasMaxLength(GlobalConsts.StringLengthShort); builder.Property(e => e.SocialMediaX) .HasMaxLength(GlobalConsts.StringLengthShort); builder.Property(e => e.SocialMediaFacebook) .HasMaxLength(GlobalConsts.StringLengthShort); builder.Property(e => e.SocialMediaInstagram) .HasMaxLength(GlobalConsts.StringLengthShort); builder.Property(e => e.SocialMediaTikTok) .HasMaxLength(GlobalConsts.StringLengthShort); builder.Property(e => e.OtherInformation1) .HasMaxLength(GlobalConsts.StringLengthMedium); builder.Property(e => e.OtherInformation2) .HasMaxLength(GlobalConsts.StringLengthMedium); builder.Property(e => e.OtherInformation3) .HasMaxLength(GlobalConsts.StringLengthMedium); builder.HasOne(e => e.Grade) .WithMany() .HasForeignKey(e => e.GradeId) .OnDelete(DeleteBehavior.NoAction); builder.HasOne(e => e.Branch) .WithMany() .HasForeignKey(e => e.BranchId) .OnDelete(DeleteBehavior.NoAction); builder.HasOne(e => e.Department) .WithMany() .HasForeignKey(e => e.DepartmentId) .OnDelete(DeleteBehavior.NoAction); builder.HasOne(e => e.Designation) .WithMany() .HasForeignKey(e => e.DesignationId) .OnDelete(DeleteBehavior.NoAction); builder.HasMany(e => e.EmployeeIncome) .WithOne(ei => ei.Employee) .HasForeignKey(ei => ei.EmployeeId) .OnDelete(DeleteBehavior.NoAction); builder.HasMany(e => e.EmployeeDeduction) .WithOne(ed => ed.Employee) .HasForeignKey(ed => ed.EmployeeId) .OnDelete(DeleteBehavior.NoAction); builder.HasIndex(e => new { e.TenantId, e.AutoNumber }).IsUnique(); builder.HasIndex(e => new { e.TenantId, e.Code }).IsUnique(); builder.HasIndex(e => e.FirstName); builder.HasIndex(e => e.LastName); builder.HasIndex(e => e.IdentityNumber); builder.HasIndex(e => e.Email); builder.HasIndex(e => e.GradeId); builder.HasIndex(e => e.BranchId); builder.HasIndex(e => e.DepartmentId); builder.HasIndex(e => e.DesignationId); } }