feat: enhance workshop handling by adding workshop group association and improving initialization logic
This commit is contained in:
@@ -10,11 +10,12 @@ public class InstitutionContractWorkshopCurrent:InstitutionContractWorkshopBase
|
||||
public InstitutionContractWorkshopCurrent(string workshopName, bool hasRollCallPlan,
|
||||
bool hasRollCallPlanInPerson, bool hasCustomizeCheckoutPlan, bool hasContractPlan,
|
||||
bool hasContractPlanInPerson, bool hasInsurancePlan, bool hasInsurancePlanInPerson,
|
||||
int personnelCount, double price,long institutionContractWorkshopGroupId,long workshopId) : base(workshopName, hasRollCallPlan,
|
||||
int personnelCount, double price,long institutionContractWorkshopGroupId,InstitutionContractWorkshopGroup workshopGroup,long workshopId) : base(workshopName, hasRollCallPlan,
|
||||
hasRollCallPlanInPerson, hasCustomizeCheckoutPlan, hasContractPlan,
|
||||
hasContractPlanInPerson, hasInsurancePlan, hasInsurancePlanInPerson, personnelCount, price)
|
||||
{
|
||||
InstitutionContractWorkshopGroupId = institutionContractWorkshopGroupId;
|
||||
WorkshopGroup = workshopGroup;
|
||||
WorkshopId = workshopId;
|
||||
}
|
||||
public long InstitutionContractWorkshopGroupId { get; private set; }
|
||||
|
||||
@@ -31,7 +31,7 @@ public class InstitutionContractWorkshopInitial:InstitutionContractWorkshopBase
|
||||
WorkshopCreated = true;
|
||||
WorkshopCurrent = new InstitutionContractWorkshopCurrent(WorkshopName,Services.RollCall,Services.RollCallInPerson,
|
||||
Services.CustomizeCheckout,Services.Contract,Services.ContractInPerson,Services.Insurance,
|
||||
Services.InsuranceInPerson,PersonnelCount,Price,InstitutionContractWorkshopGroupId,workshopId);
|
||||
Services.InsuranceInPerson,PersonnelCount,Price,InstitutionContractWorkshopGroupId,WorkshopGroup,workshopId);
|
||||
WorkshopCurrent.SetEmployers(Employers.Select(x=>x.EmployerId).ToList());
|
||||
}
|
||||
|
||||
@@ -49,6 +49,12 @@ public class InstitutionContractWorkshopInitial:InstitutionContractWorkshopBase
|
||||
entity.SetEmployers(employerIds);
|
||||
return entity;
|
||||
}
|
||||
|
||||
public void SetWorkshopGroup(InstitutionContractWorkshopGroup entityWorkshopGroup)
|
||||
{
|
||||
InstitutionContractWorkshopGroupId = entityWorkshopGroup.id;
|
||||
WorkshopGroup = entityWorkshopGroup;
|
||||
}
|
||||
}
|
||||
|
||||
public class InstitutionContractWorkshopDetailEmployer : EntityBase
|
||||
|
||||
@@ -2190,10 +2190,19 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
||||
|
||||
var workshopsCount = institutionContractTemp.Workshops.Count.ToString();
|
||||
|
||||
var workshopDetails = institutionContractTemp.Workshops.Select(x =>
|
||||
new InstitutionContractWorkshopInitial(x.WorkshopName, x.RollCall, x.RollCallInPerson, x.CustomizeCheckout,
|
||||
x.ContractAndCheckout,
|
||||
x.ContractAndCheckoutInPerson, x.Insurance, x.InsuranceInPerson, x.CountPerson, x.Price)).ToList();
|
||||
var workshopDetails = institutionContractTemp
|
||||
.Workshops.Select(x =>
|
||||
{
|
||||
var res = new InstitutionContractWorkshopInitial(x.WorkshopName, x.RollCall, x.RollCallInPerson,
|
||||
x.CustomizeCheckout,
|
||||
x.ContractAndCheckout,
|
||||
x.ContractAndCheckoutInPerson, x.Insurance, x.InsuranceInPerson, x.CountPerson, x.Price);
|
||||
if (x.WorkshopId != 0)
|
||||
{
|
||||
res.SetWorkshopId(x.WorkshopId);
|
||||
}
|
||||
return res;
|
||||
}).ToList();
|
||||
|
||||
var employeeCount = institutionContractTemp.Workshops.Sum(x => x.CountPerson).ToString();
|
||||
|
||||
@@ -2218,11 +2227,35 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
||||
extensionNo, workshopsCount, employeeCount,
|
||||
previousInstitutionContract.Description,
|
||||
"NotOfficial", "JobRelation", hasValueAddedTax,
|
||||
payment.Tax.MoneyToDouble(), workshopDetails);
|
||||
payment.Tax.MoneyToDouble(),[]);
|
||||
|
||||
await CreateAsync(entity);
|
||||
await SaveChangesAsync();
|
||||
foreach (var workshop in institutionContractTemp.Workshops)
|
||||
{
|
||||
var workshopDetail = new InstitutionContractWorkshopInitial(
|
||||
workshop.WorkshopName, workshop.RollCall, workshop.RollCallInPerson,
|
||||
workshop.CustomizeCheckout, workshop.ContractAndCheckout,
|
||||
workshop.ContractAndCheckoutInPerson, workshop.Insurance,
|
||||
workshop.InsuranceInPerson, workshop.CountPerson, workshop.Price);
|
||||
|
||||
workshopDetail.SetWorkshopGroup(entity.WorkshopGroup);
|
||||
|
||||
if (workshop.WorkshopId != 0)
|
||||
{
|
||||
workshopDetail.SetWorkshopId(workshop.WorkshopId);
|
||||
}
|
||||
// Set parent reference
|
||||
|
||||
// Add to the parent's collection
|
||||
entity.WorkshopGroup.InitialWorkshops.Add(workshopDetail);
|
||||
}
|
||||
|
||||
// Save the changes again
|
||||
await SaveChangesAsync();
|
||||
|
||||
|
||||
|
||||
FinancialStatment financialStatement;
|
||||
if (_context.FinancialStatments.Any(x => x.ContractingPartyId == contractingParty.id))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user