Exemplo n.º 1
0
        public IActionResult Index()
        {
            ProductsViewModel p = new ProductsViewModel();

            p.Products = _iProductUI.GetAllProducts().Take(6).ToList();
            p.Title    = "Product from database";
            p.SubTitle = "There is six products from database!";

            ProductsViewModel p1 = new ProductsViewModel();

            p1.Products = _iProductUI.PreferredProducts().Take(6).ToList();
            p1.Title    = "Preferred products";
            p1.SubTitle = "There is six preferred products from database";

            ProductsViewModel p2 = new ProductsViewModel();

            p2.Products = _iProductUI.NewestProducts().Take(6).ToList();
            p2.Title    = "Newset products";
            p2.SubTitle = "There is six newest products from database";

            ProductsViewModel p3 = new ProductsViewModel();

            p3.Products = _iProductUI.BestBuyProducts().Take(6).ToList();
            p3.Title    = "Best Buy products";
            p3.SubTitle = "There is six best buy products from database";

            return(View(new List <ProductsViewModel>()
            {
                p, p1, p2, p3
            }));
        }
Exemplo n.º 2
0
        public IActionResult PreferredProducts(string search = "", int page = 1)
        {
            ProductsViewModel p = new ProductsViewModel();

            p.Title    = "Preferred products";
            p.SubTitle = "There is all preferred products";
            var products = _iProductUI.PreferredProducts();

            if (!string.IsNullOrEmpty(search))
            {
                products = _iProductUI.SearchProducts(products, search);
            }

            p.SearchAllowed       = true;
            p.Products            = products.Skip((page - 1) * PageSize).Take(PageSize).ToList();
            p.PagingInfoViewModel = new PagingInfoViewModel {
                CurrentPage = page, ItemPerPage = PageSize, TotalItems = products.Count()
            };
            return(View("Index", new List <ProductsViewModel>()
            {
                p
            }));
        }