public IActionResult IndexPost(CardIndexViewModel homeIndexVm) { homeIndexVm = CardHelpers.SetDefaultFindModel(homeIndexVm); CardHelpers.SetupViewBag(homeIndexVm, ViewBag); var vmData = JsonConvert.SerializeObject(homeIndexVm); HttpContext.Session.SetString(SearchVMCacheKey, vmData); return(RedirectToAction("Index")); }
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)); }