Files
Backend-Api/CompanyManagment.EFCore/Mapping/CheckoutMapping.cs

101 lines
4.7 KiB
C#

using System;
using _0_Framework.Application;
using _0_Framework.InfraStructure;
using Company.Domain.CheckoutAgg;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace CompanyManagment.EFCore.Mapping;
class CheckoutMapping : IEntityTypeConfiguration<Checkout>
{
public void Configure(EntityTypeBuilder<Checkout> builder)
{
builder.ToTable("Checkouts");
builder.HasKey(x => x.id);
builder.Property(x => x.EmployeeFullName).HasMaxLength(50);
builder.Property(x => x.ContractNo).HasMaxLength(50);
builder.Property(x => x.FathersName).HasMaxLength(20);
builder.Property(x => x.NationalCode).HasMaxLength(10);
builder.Property(x => x.DateOfBirth).HasMaxLength(10);
builder.Property(x => x.WorkshopName).HasMaxLength(70);
builder.Property(x => x.Month).HasMaxLength(10);
builder.Property(x => x.Year).HasMaxLength(4);
builder.Property(x => x.SumOfWorkingDays).HasMaxLength(6);
builder.Property(x => x.ArchiveCode).HasMaxLength(15);
builder.Property(x => x.PersonnelCode).HasMaxLength(10);
builder.Property(x => x.TotalClaims).HasMaxLength(25);
builder.Property(x => x.TotalDeductions).HasMaxLength(25);
builder.Property(x => x.IsActiveString).HasMaxLength(10);
builder.Property(x => x.Signature).HasMaxLength(20);
builder.Property(x => x.MarriedAllowance);
builder.Property(x => x.FamilyAllowance);
builder.Property(x => x.HousingAllowance);
builder.Property(x => x.ConsumableItems);
builder.Property(x => x.RewardPay).HasColumnType("float").IsRequired(false);
builder.Property(x => x.LeaveCheckout);
builder.Property(x => x.CreditLeaves);
builder.Property(x => x.AbsencePeriod);
builder.Property(x => x.AverageHoursPerDay);
builder.Property(x => x.HasRollCall);
builder.Property(x => x.OverTimeWorkValue).HasMaxLength(10);
builder.Property(x => x.OverNightWorkValue).HasMaxLength(10);
builder.Property(x => x.FridayWorkValue).HasMaxLength(10);
builder.Property(x => x.RotatingShiftValue).HasMaxLength(10);
builder.Property(x => x.AbsenceValue).HasMaxLength(10);
builder.Property(x => x.TotalDayOfLeaveCompute).HasMaxLength(10);
builder.Property(x => x.TotalDayOfYearsCompute).HasMaxLength(10);
builder.Property(x => x.TotalDayOfBunosesCompute).HasMaxLength(10);
builder.HasOne(x => x.Workshop)
.WithMany(x => x.Checkouts)
.HasForeignKey(x => x.WorkshopId);
builder.OwnsMany(x => x.LoanInstallments, installments =>
{
installments.Property(x => x.AmountForMonth).HasMaxLength(25);
installments.Property(x => x.IsActive).HasConversion(
v => v.ToString(),
v => (IsActive)Enum.Parse(typeof(IsActive), v)).HasMaxLength(5);
installments.Property(x => x.Year).HasMaxLength(4);
installments.Property(x => x.Month).HasMaxLength(2);
installments.Property(x => x.LoanRemaining).HasMaxLength(25);
installments.Property(x => x.LoanAmount).HasMaxLength(30);
});
builder.OwnsMany(x => x.SalaryAids, salaryAid =>
{
salaryAid.Property(x => x.SalaryAidDateTimeFa).HasMaxLength(15);
salaryAid.Property(x => x.Amount).HasMaxLength(25);
salaryAid.Property(x => x.CalculationDateTimeFa).HasMaxLength(15);
});
builder.OwnsOne(x => x.CheckoutRollCall, rollCall =>
{
rollCall.Property(x => x.TotalPresentTimeSpan).HasTimeSpanConversion();
rollCall.Property(x => x.TotalBreakTimeSpan).HasTimeSpanConversion();
rollCall.Property(x => x.TotalWorkingTimeSpan).HasTimeSpanConversion();
rollCall.Property(x => x.TotalPaidLeaveTmeSpan).HasTimeSpanConversion();
rollCall.Property(x => x.TotalSickLeaveTimeSpan).HasTimeSpanConversion();
rollCall.Property(x => x.TotalMandatoryTimeSpan).HasTimeSpanConversion();
rollCall.OwnsMany(x => x.RollCallDaysCollection, rollCallDay =>
{
rollCallDay.HasKey(x => x.Id);
rollCallDay.WithOwner().HasForeignKey(x => x.CheckoutId);
rollCallDay.Property(x => x.WorkingTimeSpan).HasTimeSpanConversion();
rollCallDay.Property(x => x.BreakTimeSpan).HasTimeSpanConversion();
rollCallDay.Property(x => x.FirstStartDate).HasMaxLength(18);
rollCallDay.Property(x => x.FirstEndDate).HasMaxLength(18);
rollCallDay.Property(x => x.SecondStartDate).HasMaxLength(18);
rollCallDay.Property(x => x.SecondEndDate).HasMaxLength(18);
rollCallDay.Property(x => x.LeaveType).HasMaxLength(18);
});
});
}
}