// GET: Admin public ActionResult Index() { var productListViewModel = new ProductListViewModal { Products = _productService.GetAll() }; return(View(productListViewModel)); }
// GET: Product public ActionResult Index(int page = 1, int category = 0) { int pageSize = 10; var products = _productService.GetByCategoryId(category); var model = new ProductListViewModal { Products = products.Skip((page - 1) * pageSize).Take(pageSize).ToList(), PageCount = (int)(Math.Ceiling(products.Count / (double)pageSize)), PageSize = pageSize, CurrenCategory = category, CurrenPage = page }; return(View(model)); }
public ViewResult List(string category, int page = 1) { var model = new ProductListViewModal { 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 = repository.Products.Count(p => category == null || p.Category == category) }, CurrentCategory = category }; return(View(model)); }