Esempio n. 1
0
        // GET: Admin
        public ActionResult Index()
        {
            var productListViewModel = new ProductListViewModal
            {
                Products = _productService.GetAll()
            };

            return(View(productListViewModel));
        }
Esempio n. 2
0
        // 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));
        }
Esempio n. 3
0
        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));
        }