public ActionResult Index(ProductsIndexVM model) { var products = ProductService.GetProductsInfo(model.SearchString, model.Price, model.IsLessThan); model.Products = products; return(View(model)); }
public IActionResult Index(int categoryId, string sortBy, int page = 1, bool All = false) { ProductsIndexVM model = new ProductsIndexVM { CategoryId = categoryId, Categories = catRepo.GetAll().ToList <Category>() }; model.SortBy = sortBy; if (categoryId == default(int)) { model.Products = repository .Paginate(page, repository.GetAll().Count(), p => p.ID, null, m => m.ProductImageMappings); } else { model.Products = repository .Paginate(page, Constants.PageSize, p => p.ID, p => p.CategoryID == categoryId, m => m.ProductImageMappings); } ViewBag.images = imgRepo.GetAll(); if (All == true) { ViewBag.All = true; model.Products = repository .Paginate(page, 4, p => p.Price, p => p.CategoryID == categoryId, m => m.ProductImageMappings); switch (sortBy) { case "Low": break; case "High": model.Products.Reverse(); break; default: break; } return(View(model)); } else { return(View(model)); } }
public IActionResult Index(int categoryId, int page = 1) { ProductsIndexVM model = new ProductsIndexVM { CategoryId = categoryId, Categories = catRepo.GetAll().ToList <Category>() }; if (categoryId == default(int)) { model.Products = repository .Paginate(page, Constants.PageSize, p => p.ID, null, p => p.Category); } else { model.Products = repository .Paginate(page, Constants.PageSize, p => p.ID, p => p.CategoryID == categoryId, p => p.Category); } return(View(model)); }