public async Task <IActionResult> Index() { if (!_cache.TryGetValue("muscleGroup", out list)) { list = await _muscleGroupService.FindAllAsync(); _cache.Set("muscleGroup", list, cacheOptions); } else { list = _cache.Get("muscleGroup") as List <MuscleGroup>; } return(View(list)); }
// Criar Get: public async Task <IActionResult> Create() { if (!_cache.TryGetValue("muscleGroup", out list2)) { list2 = await _muscleGroupService.FindAllAsync(); _cache.Set("muscleGroup", list2, cacheOptions); } else { list2 = _cache.Get("muscleGroup") as List <MuscleGroup>; } ViewBag.MuscleGroupId = new SelectList(list2, "Id", "Name"); return(View()); }