public async Task <OrderForPageDto> GetAllIncludeForPropertyAsync(OrderDto dto, CancellationToken token = default) { using (var db = new GuoGuoCommunityContext()) { var list = db.Orders.Include(x => x.Shop).Where(item => item.Industry.BuildingUnit.Building.SmallDistrictId.ToString() == dto.SmallDistrictId && (item.OrderStatusValue != OrderStatus.WaitingAccept.Value) && item.PaymentStatusValue == PaymentStatus.Paid.Value); if (!string.IsNullOrEmpty(dto.OrderStatusValue)) { list = list.Where(item => item.OrderStatusValue == dto.OrderStatusValue); } if (!string.IsNullOrEmpty(dto.Number)) { list = list.Where(item => item.Number.Contains(dto.Number)); } if (!string.IsNullOrEmpty(dto.ShopId)) { list = list.Where(item => item.ShopId.ToString() == dto.ShopId); } list = list.OrderByDescending(item => item.CreateOperationTime); List <Order> resultList = await list.Skip((dto.PageIndex - 1) *dto.PageSize).Take(dto.PageSize).ToListAsync(token); OrderForPageDto pagelist = new OrderForPageDto { List = resultList, Count = list.Count() }; return(pagelist); } }
public async Task <OrderForPageDto> GetAllIncludeForPageAsync(OrderDto dto, CancellationToken token = default) { using (var db = new GuoGuoCommunityContext()) { var list = db.Orders.Include(x => x.Shop).Where(item => item.IsDeleted == false && item.CreateOperationUserId.ToString() == dto.OperationUserId); if (!string.IsNullOrEmpty(dto.OrderStatusValue)) { if (dto.OrderStatusValue == "All") { } else if (dto.OrderStatusValue == "WaitingTake") { list = list.Where(item => item.OrderStatusValue == "WaitingTake" || item.OrderStatusValue == "WaitingSend"); } else { list = list.Where(item => item.OrderStatusValue == dto.OrderStatusValue); } } list = list.OrderByDescending(item => item.CreateOperationTime); List <Order> resultList = await list.Skip((dto.PageIndex - 1) *dto.PageSize).Take(dto.PageSize).ToListAsync(token); OrderForPageDto pagelist = new OrderForPageDto { List = resultList, Count = list.Count() }; return(pagelist); } }