//public IActionResult Index() //{ // List<ShowAll> result = (List<ShowAll>)productRepository.showProduct(); // List<Shop_Sneaker.Entities.Category> categoriesShow = categoryRepository.Gets(); // List<BannerViewModel> bannerModels = bannerRepository.Gets(); // var homeView = new HomeViewModel() // { // bannerViewModels = bannerModels, // categories = categoriesShow, // showAlls = result // }; // return View(homeView); //} //[AllowAnonymous] public async Task <IActionResult> Index(int currenPage, int pageSize, int categoryId) { var categories = categoryRepository.Gets(); List <ShowAll> products = new List <ShowAll>(); if (categoryId > 0 && categories != null) { products = (await productRepository.GetProductsInCategory(categoryId)).ToList(); } else { if (categories.Any()) { products = (await productRepository.GetProductsInCategory(categories[0].CategoryId)).ToList(); } }; if (currenPage == 0) { currenPage = 1; } if (pageSize == 0) { pageSize = 8; } var pager = new Pager(products.Count, currenPage, pageSize); var pagination = new Pagination <ShowAll>() { ListItems = products.Skip((currenPage - 1) * pageSize).Take(pageSize), Pager = pager, bannerModels = bannerRepository.Gets(), categoriesShow = categories }; return(View(pagination)); }
public IActionResult Index() { var Categories = bannerRepositori.Gets(); return(View(Categories)); }
public IActionResult Index() { var banners = bannerRepositori.Gets(); return(View(banners)); }