public IActionResult Index(string search, int pageNumber) { List <Newsletter> newsletters = new List <Newsletter>(); if (!String.IsNullOrEmpty(search)) { newsletters = _newsletterRepository.Search(search).ToList(); pageNumber = 1; } else { newsletters = _newsletterRepository.GetAll().ToList(); } int pageSize = 10; pageNumber = (pageNumber > 0) ? pageNumber : 1; return(View(PaginatorExtension <Newsletter> .CreateAsync(newsletters, pageNumber, pageSize))); }