public ActionResult AddQuestion(NewQuestion newQuestion) { TempData["Selected_New"] = "selected"; Survey survey = _repository.GetSurvey(newQuestion.SurveyId); Question question = new Question(); question.Live = 1; question.Number = survey.Questions.OrderBy(o => o.Number).Select(o => o.Number).LastOrDefault() + 1; question.Text = newQuestion.QuestionText; question.Survey = newQuestion.SurveyId; int success = _repository.CreateQuestion(question); if (success != 0) { return RedirectToAction("AddAnswer", new { surveyId = question.Survey, questionId = success }); } return View(newQuestion); }
public ActionResult AddQuestion(int surveyId) { // Adds the class 'selected' to top navigation TempData["Selected_New"] = "selected"; // Adds the class 'Selected' to the left navigation TempData["Step-2"] = "Selected"; Survey survey = _repository.GetSurvey(surveyId); NewQuestion vm = new NewQuestion(); vm.SurveyId = surveyId; vm.SurveyTitle = survey.Title; // Counts number of questions exiting and assigns next number for order vm.QuestionOrder = survey.Questions.Count() + 1; vm.Summary = ConvertFullSurvey(survey); return View(vm); }