public async Task <IActionResult> Index(int?StudentId) { if (StudentId == null) { return(RedirectToAction(nameof(Error), new { message = "Id nulo" })); } var obj = _sheetService.FindByIdAsync(StudentId); if (obj == null) { return(RedirectToAction(nameof(Error), new { message = "Id não encontrado" })); } if (!_cache.TryGetValue("sheet" + StudentId, out list)) { list = await _sheetService.FindAllAsync(StudentId); _cache.Set("sheet" + StudentId, list, cacheOptions); } else { list = _cache.Get("sheet" + StudentId) as List <Sheet>; } ViewBag.studentName = (await _studentService.FindByIdAsync(StudentId)).Name; return(View(list.OrderBy(x => x.Id))); }