public async Task <IActionResult> InventoryStockLoctionReport(DataSourceRequest command, InventoryStockListModel model) { var(invStockListModel, totalCount) = await _inventoryManagementService.PrepareInvStockLocationListModel(model, command.Page, command.PageSize); var gridModel = new DataSourceResult { Data = invStockListModel, Total = totalCount }; return(Json(gridModel)); }
public async Task <(IEnumerable <InventoryStockModel> invStockListModel, int totalCount)> PrepareInvStockLocationListModel(InventoryStockListModel model, int pageIndex, int pageSize) { var query = from v in _itemRepository.Table join i in _inventoryRepository.Table on v.VitemId equals i.VitemId join ve in _vendorRepository.Table on v.VendorId equals ve.VendorId where i.ClientId == (int)_workContext.CurrentCustomer.ClientId select new InventoryStockModel { Bin = "", StoreRoom = i.Ivname, Category = i.Category, Item = v.Vitem, VitemID = v.VitemId, Description = v.Vdescription, Unit = v.Uom, Pkg = v.Pkg, Price = v.SellingPrice, OnHand = i.Iqty, OnOrder = i.IonOrder, DeptRequest = i.DeptResp, InventID = i.InventId }; //Sorting if (model.intSort == 10) { query = query.OrderBy(c => c.StoreRoom); } if (model.intSort == 9) { query = query.OrderBy(c => c.Category); } if (model.intSort == 2) { query = query.OrderBy(c => c.Description); } if (model.intSort == 4) { query = query.OrderBy(c => c.DeptRequest); } if (model.intSort == 8) { query = query.OrderBy(c => c.OnHand); } if (model.intSort == 11) { query = query.OrderBy(c => c.Item); } //Searching Criteria if (!string.IsNullOrWhiteSpace(model.strSearch)) { query = query.Where(b => b.Description.Contains(model.strSearch) || b.StoreRoom.Contains(model.strSearch) || b.Category.Contains(model.strSearch) || b.Item.Contains(model.strSearch)); } var invStockListModel = query.ToList(); int totalCount = invStockListModel.Count; int pageOffSet = (Convert.ToInt32(pageIndex) - 1) * 10; invStockListModel = invStockListModel.Skip(pageOffSet).Take(Convert.ToInt32(pageSize)).ToList(); return(invStockListModel, totalCount); }