public async Task <IActionResult> QuesForTest(int id, QuesGiveTestViewModel model) { try { var email = await GetEmail(); var student = _studentService.GetStudentByEmail(email); _responseService.Add(model.TestId, student.Id, model); ViewBag.Id = model.TestId; var count = _testQuesService.GetTestQuesByTestId(model.TestId).Count(); ViewBag.Count = count; if (count <= model.No) { return(RedirectToAction("TestCompleted")); } var question = _questionService.GetQuestionForGivingTest(model.TestId, model.No + 1); ViewBag.No = ++model.No; return(View(question)); } catch (Exception e) { ViewBag.Error = "Something went wrong"; return(View("TestCompleted")); } }