Пример #1
0
        public ActionResult AddAnswer(NewAnswer newAnswer)
        {
            TempData["Selected_New"] = "selected";
            Question question = _repository.GetQuestion(newAnswer.QuestionId);

            Answer answer = new Answer();
            answer.Live = 1;
            answer.Text = newAnswer.AnswerText;
            answer.Survey = newAnswer.SurveyId;
            answer.Number = question.Answers.OrderBy(o => o.Number).Select(o => o.Number).LastOrDefault() + 1;
            answer.Question = newAnswer.QuestionId;

            int success = _repository.CreateAnswer(answer);

            if (success != 0)
            {
                return PartialView("Answer", answer);
            }

            return View(newAnswer);
        }
Пример #2
0
 /// <summary>
 /// Create a new Answer object.
 /// </summary>
 /// <param name="id">Initial value of the ID property.</param>
 /// <param name="survey">Initial value of the Survey property.</param>
 /// <param name="question">Initial value of the Question 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 Answer CreateAnswer(global::System.Int32 id, global::System.Int32 survey, global::System.Int32 question, global::System.Int32 number, global::System.String text, global::System.Int32 live)
 {
     Answer answer = new Answer();
     answer.ID = id;
     answer.Survey = survey;
     answer.Question = question;
     answer.Number = number;
     answer.Text = text;
     answer.Live = live;
     return answer;
 }
Пример #3
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Answers EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToAnswers(Answer answer)
 {
     base.AddObject("Answers", answer);
 }