public ViewResult SearchProduct(string search) { ProductsListViewModel model = new ProductsListViewModel { Products = repository.Products .Where(p => p.Description.Contains(search.ToString())) }; return View(model); }
// GET: Product Details public ViewResult Details(string id) { ProductsListViewModel model = new ProductsListViewModel { Products = repository.Products .Where(p => p.ProductID == Convert.ToInt32(id)) }; return View(model); }
// GET: Product public ViewResult List(string category, int page = 1) { ProductsListViewModel model = new ProductsListViewModel { Products = repository.Products .Where(p => category == null || p.Category == category) .OrderBy(p => p.ProductID) .Skip((page - 1) * PageSize) .Take(PageSize), PagingInfo = new PagingInfo { CurrentPage = page, ItemsPerPage = PageSize, TotalItems = category == null ? repository.Products.Count() : repository.Products.Where(e => e.Category == category).Count() }, CurrentCategory = category }; return View(model); }