boost get list

This commit is contained in:
2025-10-05 14:40:32 +03:30
parent b8c738bd14
commit 024b8cfaa9
2 changed files with 15 additions and 14 deletions

View File

@@ -1021,7 +1021,7 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
.ThenInclude(x => 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<long, InstitutionCon
contract => 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<long, InstitutionCon
5 // Active
);
var list = await orderedQuery.ApplyPagination(searchModel.PageIndex, searchModel.PageSize).ToListAsync();
var list = await orderedQuery.ApplyPagination(searchModel.PageIndex, searchModel.PageSize).ToListAsync();
var contractingPartyIds = list.Select(x => x.contractingParty.id).ToList();
var financialStatements = _context.FinancialStatments.Include(x => x.FinancialTransactionList)
.Where(x => contractingPartyIds.Contains(x.ContractingPartyId)).ToList();
var res = new PagedResult<GetInstitutionContractListItemsViewModel>()
{
TotalCount = joinedQuery.Count(),
TotalCount =await joinedQuery.CountAsync(),
List = list.Select(x =>
{
Console.WriteLine(x.contractingParty.id);
@@ -1239,6 +1238,8 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
List<InstitutionContractWorkshopBase> currentStateWorkshops = x.contract.WorkshopGroup?.CurrentWorkshops
.Cast<InstitutionContractWorkshopBase>().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<long, InstitutionCon
return new GetInstitutionContractListItemsViewModel()
{
ContractAmount = x.contract.ContractAmount,
Balance = x.statement.FinancialTransactionList.Sum(ft => 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<long, InstitutionCon
{
var @enum = Enum.Parse<InstitutionContractListStatus>(name);
searchModel.Status = @enum;
searchModel.PageSize = 1;
var count = (await GetList(searchModel)).TotalCount;
counts.Add(new() { ListStatus = @enum, Count = count });
}

View File

@@ -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);
}