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 })); }
public IActionResult NewestProducts(string search = "", int page = 1) { var products = _iProductUI.NewestProducts(); ProductsViewModel p = new ProductsViewModel(); p.Title = "Newst products"; p.SubTitle = "Ordered by data created"; p.SearchAllowed = true; if (!string.IsNullOrEmpty(search)) { products = _iProductUI.SearchProducts(products, search); } 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 })); }