reafactor: fix error of query getting data for excel data
This commit is contained in:
@@ -566,22 +566,34 @@ public class IndexModel : PageModel
|
||||
|
||||
private async System.Threading.Tasks.Task GetExcelPricingData()
|
||||
{
|
||||
_context.PersonalContractingParties.Include(x => x.Employers)
|
||||
.ThenInclude(x => x.WorkshopEmployers)
|
||||
.ThenInclude(x => x.Workshop).ThenInclude(x => ).AsSplitQuery().Select(x => new DataExcelResult()
|
||||
{
|
||||
ContractingPartyId = x.id,
|
||||
ContractingPartyName = x.FName + " " + x.LName,
|
||||
Employers = x.Employers.Select(e => new EmployerExcelResultData()
|
||||
{
|
||||
EmployerName = e.FullName,
|
||||
Id = e.id,
|
||||
Workshops = e.WorkshopEmployers.Select(we => new WorkshopExcelResultData()
|
||||
{
|
||||
Id = we.Workshop.id,
|
||||
}).ToList()
|
||||
}).ToList()
|
||||
});
|
||||
var now = DateTime.Today;
|
||||
var data =await _context.PersonalContractingParties.Include(x => x.Employers)
|
||||
.ThenInclude(x => x.WorkshopEmployers)
|
||||
.ThenInclude(x => x.Workshop).ThenInclude(x => x.LeftWorks)
|
||||
.Include(x => x.Employers)
|
||||
.ThenInclude(x => x.WorkshopEmployers)
|
||||
.ThenInclude(x => x.Workshop).ThenInclude(x => x.LeftWorkInsurances)
|
||||
.AsSplitQuery().Select(x => new DataExcelResult()
|
||||
{
|
||||
ContractingPartyId = x.id,
|
||||
ContractingPartyName = x.FName + " " + x.LName,
|
||||
Employers = x.Employers.Select(e => new EmployerExcelResultData()
|
||||
{
|
||||
EmployerName = e.FullName,
|
||||
Id = e.id,
|
||||
Workshops = e.WorkshopEmployers.Select(we => new WorkshopExcelResultData()
|
||||
{
|
||||
Id = we.Workshop.id,
|
||||
HasContract = we.Workshop.LeftWorks.Any(l => l.StartWorkDate >= now && l.LeftWorkDate <= now),
|
||||
HasRollCall =
|
||||
we.Workshop.RollCallServicesList.Any(a => a.StartService >= now && a.EndService <= now),
|
||||
HasInsurance = we.Workshop.InsuranceCode != null,
|
||||
HasCustomizeCheckout = we.Workshop.RollCallServicesList.Any(a =>
|
||||
a.StartService >= now & a.EndService <= now && a.HasCustomizeCheckoutService == "true"),
|
||||
WorkshopName = we.Workshop.WorkshopFullName
|
||||
}).ToList()
|
||||
}).ToList()
|
||||
}).ToListAsync();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
Reference in New Issue
Block a user