public async Task <IActionResult> InventoryByLastOrderDate(DataSourceRequest command, InvLastStockListModel model) { var(invLastStockListModel, totalCount) = await _inventoryManagementService.PrepareInvLastRequestListModel(model, command.Page, command.PageSize); var gridModel = new DataSourceResult { Data = invLastStockListModel, Total = totalCount }; return(Json(gridModel)); }
public async Task <(IEnumerable <DustyShelf> invLastStockListModel, int totalCount)> PrepareInvLastRequestListModel(InvLastStockListModel model, int pageIndex, int pageSize) { ///Add from store procedure response to model var dustylistmodel = new List <DustyShelf>(); int totalCount = 0; try { SqlParameter[] pr = new SqlParameter[] { new SqlParameter("@intClientID", (int)_workContext.CurrentCustomer.ClientId), new SqlParameter("@intSort", model.intSort) }; var cores = await _dbContext.Set <DustyShelf>().FromSqlRaw("exec DustyShelf @intClientID,@intSort", pr).ToListAsync(); totalCount = cores.Count; int pageOffSet = (Convert.ToInt32(pageIndex) - 1) * 10; cores = cores.Skip(pageOffSet).Take(Convert.ToInt32(pageSize)).ToList(); foreach (var p in cores) { dustylistmodel.Add(new DustyShelf { MaxOfHDate = p.MaxOfHDate, VDescription = p.VDescription, VItem = p.VItem, VName = p.VName }); } } catch (Exception ex) { } return(dustylistmodel, totalCount); }