public IActionResult Answer(int id) { string un = Request.Cookies["username"]; if (string.IsNullOrWhiteSpace(un)) { return(View("Error", "Invalid username!")); } ARQuizz.Session s = ARQuizz.Session.GetCurrentSession(un); if (s == null) { return(View("Error", "Session timed out!")); } s.Answer(id); if (s.IsLastQuestion()) { return(Redirect("/Home/GetQuizzResult/-1")); } return(Redirect("/Home/GetNextQuestion?UserName=" + un)); }
public async Task <IActionResult> Answer(int id) { return(await Task.Run <IActionResult>(() => { string un = Request.Cookies["username"]; if (string.IsNullOrWhiteSpace(un)) { return View("Error", "Invalid username!"); } ARQuizz.Session s = ARQuizz.Session.GetCurrentSession(un); if (s == null) { return Redirect("/Quizz/ShowYourResult/" + un); } Task.WaitAll(s.Answer(id)); if (s.IsLastQuestion()) { return Redirect("/Quizz/Result/-1"); } if (id == -1) { return Redirect("/Quizz/GetQuizzResult?UserName="******"/Quizz/Question/Next?UserName=" + un); })); }