public async Task <IActionResult> Filter(string sortOrder, string searchTerm, int?pageNumber, int?pageSize) { sortOrder = sortOrder ?? string.Empty; searchTerm = searchTerm ?? string.Empty; var spells = await _spellService.FilterSpellsAsync(sortOrder, searchTerm, pageNumber ?? 1, pageSize ?? 10); var model = new SpellIndexViewModel(spells, sortOrder, searchTerm); return(PartialView("_SpellTablePartial", model.Table)); }
public async Task <IActionResult> Index() { if (!_memoryCache.TryGetValue("ListOfSpells", out IPagedList <Spell> spells)) { spells = await _spellService.FilterSpellsAsync(); MemoryCacheEntryOptions options = new MemoryCacheEntryOptions { AbsoluteExpirationRelativeToNow = TimeSpan.FromSeconds(25), SlidingExpiration = TimeSpan.FromSeconds(5) }; _memoryCache.Set("ListOfSpells", spells, options); } var model = new SpellIndexViewModel(spells); return(View(model)); }