public ActionResult GetProducts(int pageIndex, string filter) { var products = _productCache.GetProducts().OrderBy(x => x.Id); if (!string.IsNullOrEmpty(filter)) { products = products.Where(x => x.Name.Contains(filter)).OrderBy(x => x.Id); } var productListPaged = products.Skip((pageIndex) * PAGE_SIZE).Take(PAGE_SIZE); var homeViewModel = new HomeViewModel() { CurrentIndex = pageIndex, Products = productListPaged, TotalCount = products.Count(), PageSize = PAGE_SIZE }; return(PartialView(@"~/Views/Home/_Products.cshtml", homeViewModel)); }
public List <Product> GetProducts(int skip, int count) { return(_productCache.GetProducts().Skip(skip).Take(count).ToList()); }