public async Task <IActionResult> Filter(string sortOrder, string searchTerm, int?pageNumber, int?pageSize) { sortOrder = sortOrder ?? string.Empty; searchTerm = searchTerm ?? string.Empty; var champions = await _championService.FilterChampionsAsync(sortOrder, searchTerm, pageNumber ?? 1, pageSize ?? 10); var model = new ChampionIndexViewModel(champions, sortOrder, searchTerm); return(PartialView("_ChampionTablePartial", model.Table)); }
public async Task <IActionResult> Index() { if (!_memoryCache.TryGetValue("ListOfChampions", out IPagedList <Champion> champions)) { champions = await _championService.FilterChampionsAsync(); MemoryCacheEntryOptions options = new MemoryCacheEntryOptions { AbsoluteExpirationRelativeToNow = TimeSpan.FromSeconds(25), SlidingExpiration = TimeSpan.FromSeconds(5) }; _memoryCache.Set("ListOfChampions", champions, options); } var model = new ChampionIndexViewModel(champions); return(View(model)); }