feat: update InstitutionContractRepository to enhance workshop change tracking and improve data handling

This commit is contained in:
2025-10-25 15:23:48 +03:30
parent 818d88d859
commit c36e81e263

View File

@@ -2693,15 +2693,15 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
var newWorkshops = amendmentTemp
.NewWorkshops.Where(x=>x.CurrentWorkshopId ==0).ToList();
var newWorkshopTempIds = newWorkshops.Select(x=>x.Id);
var newWorkshopTempIds = newWorkshops.Select(x=>x.Id).ToList();
var changes = newWorkshops.Select(x=>
new InstitutionContractAmendmentChange(InstitutionContractAmendmentChangeType.WorkshopCreated,
DateTime.Now,x.CustomizeCheckout,x.ContractAndCheckout,x.ContractAndCheckoutInPerson,
x.Insurance,x.InsuranceInPerson,x.CountPerson,x.RollCall,x.RollCallInPerson,0));
x.Insurance,x.InsuranceInPerson,x.CountPerson,x.RollCall,x.RollCallInPerson,0)).ToList();
var changedWorkshops = amendmentTemp.NewWorkshops
.Where(x => !newWorkshopTempIds.Contains(x.Id));
.Where(x => !newWorkshopTempIds.Contains(x.Id)).ToList();
foreach (var changedWorkshop in changedWorkshops)
{
@@ -2737,7 +2737,7 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
if (changedBooleans.Any())
{
var change = new InstitutionContractAmendmentChange(
InstitutionContractAmendmentChangeType.WorkshopUpdated,
InstitutionContractAmendmentChangeType.Services,
DateTime.Now,
changedWorkshop.CustomizeCheckout,
changedWorkshop.ContractAndCheckout,
@@ -2747,15 +2747,35 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
changedWorkshop.CountPerson,
changedWorkshop.RollCall,
changedWorkshop.RollCallInPerson,
changedWorkshop.Id);
changedWorkshop.WorkshopId);
changes = changes.Append(change);
changes.Add(change);
}
if (changedWorkshop.CountPerson != prev.CountPerson)
{
var change = new InstitutionContractAmendmentChange(
InstitutionContractAmendmentChangeType.PersonCount,
DateTime.Now,
changedWorkshop.CustomizeCheckout,
changedWorkshop.ContractAndCheckout,
changedWorkshop.ContractAndCheckoutInPerson,
changedWorkshop.Insurance,
changedWorkshop.InsuranceInPerson,
changedWorkshop.CountPerson,
changedWorkshop.RollCall,
changedWorkshop.RollCallInPerson,
changedWorkshop.WorkshopId);
changes.Add(change);
}
}
var amendment = new InstitutionContractAmendment(institutionContract.id,installments,amount,
request.IsInstallment,new List<InstitutionContractAmendmentChange>(),request.LawId);
request.IsInstallment,changes,request.LawId);
institutionContract.AddAmendment(amendment);
//Todo : ارسال پیامک تغییرات - و ذخیره تغییرات
}