public ActionResult NewQuestion(int? questionId, int? answerIndex, int? slidebarValue) { if (questionId == null) { return HttpNotFound(); } Question question = db.Questions.Find(questionId); if (question == null) return HttpNotFound(); if (question.Type == QuestionType.SlideBar) EcoCalculator.Calculate(question, (int)slidebarValue); else EcoCalculator.Calculate(question, question.Answers[(int)answerIndex]); Question nextQuestion = question.Type == QuestionType.Branching ? question.Answers[(int)answerIndex].NextQuestion : question.NextQuestion; if (nextQuestion == null) return RedirectToAction("EndResults"); return RedirectToAction("Index", new { questionId = nextQuestion.ID }); }
public ActionResult EndResults() { return View(EcoCalculator.GetFinalResults()); }