public async Task <IActionResult> Index() { var value = HttpContext.Session.GetString(SearchVMCacheKey); CardIndexViewModel cardIndexViewModel = string.IsNullOrEmpty(value) ? CardHelpers.SetDefaultFindModel(new CardIndexViewModel()) : JsonConvert.DeserializeObject <CardIndexViewModel>(value); CardHelpers.SetupViewBag(cardIndexViewModel, ViewBag); var result = await _cardRepository.ConfigureSearchAsync(cardIndexViewModel); var count = await _cardRepository.GetTotalCards(); ViewBag.MaxPage = count / cardIndexViewModel.Page; ViewBag.Page = cardIndexViewModel.Page; cardIndexViewModel.Cards = result; return(View(cardIndexViewModel)); }