/// <summary> /// Deprecated Method for adding a new object to the Questions EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToQuestions(Question question) { base.AddObject("Questions", question); }
/// <summary> /// Create a new Question object. /// </summary> /// <param name="id">Initial value of the ID property.</param> /// <param name="survey">Initial value of the Survey property.</param> /// <param name="number">Initial value of the Number property.</param> /// <param name="text">Initial value of the Text property.</param> /// <param name="live">Initial value of the Live property.</param> public static Question CreateQuestion(global::System.Int32 id, global::System.Int32 survey, global::System.Int32 number, global::System.String text, global::System.Int32 live) { Question question = new Question(); question.ID = id; question.Survey = survey; question.Number = number; question.Text = text; question.Live = live; return question; }
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); }