public IActionResult Index(string lastName = "", int page = 1) { var source = new SourceManager(); var idStartRecord = (page - 1) * SourceManager.perPage + 1; var peopleList = source.Get2(idStartRecord, SourceManager.perPage, lastName); ViewData["Page"] = page; ViewData["Start"] = idStartRecord; ViewData["Name"] = lastName; var rec = source.GetNumberOfRecords2(lastName); var perpage = SourceManager.perPage; if (rec % perpage == 0) { ViewData["Pages"] = rec / perpage; } else { ViewData["Pages"] = rec / perpage + 1; } return(View(peopleList)); }