From 024b8cfaa9a4d3f46bea648f7c9ad27544c1b2c3 Mon Sep 17 00:00:00 2001 From: mahan Date: Sun, 5 Oct 2025 14:40:32 +0330 Subject: [PATCH] boost get list --- .../InstitutionContractRepository.cs | 20 ++++++++++--------- .../Pages/Company/AndroidApk/Index.cshtml.cs | 9 ++++----- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/CompanyManagment.EFCore/Repository/InstitutionContractRepository.cs b/CompanyManagment.EFCore/Repository/InstitutionContractRepository.cs index 32121b07..d9c4ff55 100644 --- a/CompanyManagment.EFCore/Repository/InstitutionContractRepository.cs +++ b/CompanyManagment.EFCore/Repository/InstitutionContractRepository.cs @@ -1021,7 +1021,7 @@ public class InstitutionContractRepository : RepositoryBase x.InitialWorkshops) .Include(x => x.WorkshopGroup) .ThenInclude(x => x.CurrentWorkshops) - .Include(x => x.ContactInfoList); + .Include(x => x.ContactInfoList).AsNoTracking(); var now = DateTime.Today; var nowFa = now.ToFarsi(); @@ -1035,15 +1035,10 @@ public class InstitutionContractRepository : RepositoryBase contract.ContractingPartyId, contractingParty => contractingParty.id, (contract, contractingParty) => new { contract, contractingParty }) - .Join(_context.FinancialStatments.Include(x => x.FinancialTransactionList), - x => x.contractingParty.id, - statement => statement.ContractingPartyId, - (x, statement) => new { x.contractingParty, x.contract, statement }) .Select(x => new { x.contract, x.contractingParty, - x.statement, StatusPriority = x.contract.VerificationStatus == InstitutionContractVerificationStatus.PendingForVerify ? (int)InstitutionContractListStatus.PendingForVerify @@ -1214,10 +1209,14 @@ public class InstitutionContractRepository : RepositoryBase x.contractingParty.id).ToList(); + + var financialStatements = _context.FinancialStatments.Include(x => x.FinancialTransactionList) + .Where(x => contractingPartyIds.Contains(x.ContractingPartyId)).ToList(); var res = new PagedResult() { - TotalCount = joinedQuery.Count(), + TotalCount =await joinedQuery.CountAsync(), List = list.Select(x => { Console.WriteLine(x.contractingParty.id); @@ -1239,6 +1238,8 @@ public class InstitutionContractRepository : RepositoryBase currentStateWorkshops = x.contract.WorkshopGroup?.CurrentWorkshops .Cast().ToList(); + var statement = financialStatements.FirstOrDefault(f => f.ContractingPartyId == x.contractingParty.id); + currentStateWorkshops?.AddRange( x.contract.WorkshopGroup?.InitialWorkshops.Where(w => !w.WorkshopCreated) ?? []); @@ -1270,7 +1271,7 @@ public class InstitutionContractRepository : RepositoryBase ft.Deptor - ft.Creditor), + Balance = statement?.FinancialTransactionList.Sum(ft => ft.Deptor - ft.Creditor)??0, WorkshopsCount = workshops.Count(), ContractStartFa = x.contract.ContractStartGr.ToFarsi(), ContractEndFa = x.contract.ContractEndGr.ToFarsi(), @@ -1474,6 +1475,7 @@ public class InstitutionContractRepository : RepositoryBase(name); searchModel.Status = @enum; + searchModel.PageSize = 1; var count = (await GetList(searchModel)).TotalCount; counts.Add(new() { ListStatus = @enum, Count = count }); } diff --git a/ServiceHost/Areas/AdminNew/Pages/Company/AndroidApk/Index.cshtml.cs b/ServiceHost/Areas/AdminNew/Pages/Company/AndroidApk/Index.cshtml.cs index c11d213e..d2352464 100644 --- a/ServiceHost/Areas/AdminNew/Pages/Company/AndroidApk/Index.cshtml.cs +++ b/ServiceHost/Areas/AdminNew/Pages/Company/AndroidApk/Index.cshtml.cs @@ -783,17 +783,16 @@ namespace ServiceHost.Areas.AdminNew.Pages.Company.AndroidApk }).ToList(); var group = new InstitutionContractWorkshopGroup(item.contract.id, initialWorkshop); - + + await _context.AddAsync(group); + await _context.SaveChangesAsync(); + initialWorkshop.ForEach(x => { var workshopId = workshops.First(w => x.WorkshopId.Value == w.id).id; x.SetWorkshopId(workshopId); }); - - await _context.AddAsync(group); - await _context.SaveChangesAsync(); - item.contract.SetWorkshopGroup(group); }