public RedirectToRouteResult CreateMultipleChoicesQuestion(QuestionType questionType, MultipleChoicesQuestion question) { var poll = (Poll)this.Session[PollKey]; question.Type = QuestionType.MultipleChoices; question.Order = (short)poll.Questions.Count; poll.Questions.Add(question); return this.GoToCreateQuestion(questionType); }
public ActionResult FinishAnswerMultipleChoicesQuestion(MultipleChoicesQuestion multipleChoicesQuestion) { var questionAnswer = new MultipleChoicesAnswer { SelectedChoices = new List<Choice>(multipleChoicesQuestion.Choices.Where(c => c.Selected)), QuestionId = multipleChoicesQuestion.Id }; var pollAnswer = (PollAnswer)this.Session[PollAnswerKey]; pollAnswer.QuestionAnswers.Add(questionAnswer); return this.RedirectToAction("AnswerQuestion"); }
private void CreatePoll(AppDbContext context) { var multiple = new MultipleChoicesQuestion { Type = QuestionType.MultipleChoices, Statement = "multiple choices", CanSelectMultiple = true, Choices = new List<Choice> { new Choice { Text = "11111" }, new Choice { Text = "22222" }, new Choice { Text = "33333" } } }; var freeText = new Question { Statement = "free text", Type = QuestionType.FreeText }; var poll = new Poll { Name = "agora vai", Range = 50, CreationDate = DateTime.Now, ExpirationDate = new DateTime(2020, 01, 01), CreationLocation = new Location { Latitude = 90.0f, Longitude = 50.0f }, Questions = new List<Question> { multiple, freeText }, }; context.Polls.Add(poll); context.SaveChanges(); }