public RedirectToRouteResult CreateFreeTextQuestion(QuestionType questionType, Question question) { var poll = (Poll)this.Session[PollKey]; question.Type = QuestionType.FreeText; question.Order = (short)poll.Questions.Count; poll.Questions.Add(question); return this.GoToCreateQuestion(questionType); }
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(); }