public IActionResult Navigate(int id) { int lengthPage = Convert.ToInt32(_configuration["lengthAdminPage"]); int displayPage = Convert.ToInt32(_configuration["displayAdminPage"]); int indexActuel = (id - 1) * lengthPage; _commentaires = _commentaireRepository.Take(indexActuel, (_commentaireRepository.Count() <= (id * lengthPage)) ? _commentaireRepository.Count() - indexActuel : lengthPage).Select(vm => new CommentairesViewModel { Auteur = vm.Auteur, Contenu = vm.Contenu, DateCreation = vm.DateCreation, IdCommentaire = vm.IdCommentaire, IdTitre = vm.IdTitre, NomTitre = vm.Titre.Libelle, NomArtiste = vm.Titre.Artiste.Nom, } ).ToList(); IndexCommentairesViewModel indexCommentairesViewModel = new IndexCommentairesViewModel { Commentaires = _commentaires, TotalCommentaires = _commentaireRepository.Count(), PageActuel = id, LengthPage = lengthPage, DisplayPage = displayPage, Next = (_commentaireRepository.Count() - indexActuel > lengthPage) ? true : false }; return(this.View(nameof(CommentairesController.Index), indexCommentairesViewModel)); }
public IViewComponentResult Invoke(IndexCommentairesViewModel pagination) { return(View(pagination)); }