public IActionResult Index() { int lengthPage = Convert.ToInt32(_configuration["lengthPage"]); int lengthPop = Convert.ToInt32(_configuration["lengthPop"]); var homeVM = new HomeViewModel { TitresPopulaires = _titreRepository.FindAll().OrderByDescending(x => x.NbLikes).Take(lengthPop).ToList(), DerniersTitres = _titreRepository.FindTitres(0, lengthPage).ToList(), PageActuel = 0, Next = (_titreRepository.Count() - lengthPage > 0) ? true : false }; return(View(homeVM)); }
/// <summary> /// Return the index page to be displayed /// </summary> /// /// <returns>Return the index page</returns> /// public IActionResult Index(int id) { var test = DateTime.Now.Month - 2; id = id == 0 ? 1 : id; var data = (List <Titre>)_titreRepository.FindTitres((id - 1) * 3, 3); var countitres = _titreRepository.Count(); HomeViewModel titre = new HomeViewModel() // model for the view { Titres_chroniques = data, Titres_populaires = (List <Titre>)_titreRepository.GetPopular(new DateTime(2019, 10, 1)), Page = id, MaxPage = _titreRepository.Count() / 3 }; return(this.View(titre)); }