public async Task <IActionResult> Index(int?page) { var problemList = await _problemRepository.GetAllAsync(); var goodList = new List <Problem>(); if (User.Identity.Name == null || !User.IsInRole("Admin")) { //we don't have an admin, show only the visible problem goodList = problemList.Where(prob => prob.Visible == true).ToList(); } else { goodList = problemList.ToList(); } int pageSize = 20; return(View(PaginatedList <Problem> .CreateAsync(goodList, page ?? 1, pageSize))); }