public async Task <IActionResult> Index() { int?ind = HttpContext.Session.GetInt32("question_id"); if (ind.HasValue) { Question temp = SessionHelper.GetObjectFromJson <Question>(HttpContext.Session, "question"); if (temp == null) { temp = await _dbContext.Question.FindAsync(ind.Value); } SessionHelper.SetObjectAsJson(HttpContext.Session, "question", temp); } else { return(RedirectToAction("Index", "PublicLibrary")); } var tests = await _dbContext.Tests.ToListAsync(); var models = new TestChoiceViewModel() { TestMethodsNames = tests.Select(x => x.Name).ToArray(), TestsMethodsIds = tests.Select(x => x.Id).ToArray() }; return(View(models)); }
public RedirectToActionResult Index([Bind("SelectedId, ServiceInfo")] TestChoiceViewModel temp) { if (ModelState.IsValid) { switch (temp.SelectedId) { case 1: return(RedirectToAction(nameof(MissingWordsTest), new { Instruction = temp.ServiceInfo })); case 2: return(RedirectToAction("Inwork", "Home")); default: return(RedirectToAction(nameof(Index))); } } Console.WriteLine(ModelState.Values); return(RedirectToAction(nameof(Index))); }