Exemplo n.º 1
0
        private static Question CreateWhatsYourHomeTown()
        {
            var questionBuilder = new QuestionBuilder();
            var question = questionBuilder
                                .WithQueryText("What is your home town?")
                                .AddMultipleAnswers("Sofia", "Varna", "Burgas", "Plovdiv")
                                .BuildQuestion();

            return question;
        }
Exemplo n.º 2
0
        private static Question CreateWhatsYourFavoriteProgrammingLanguage()
        {
            var questionBuilder = new QuestionBuilder();
            var question = questionBuilder
                                .WithQueryText("What is your favorite programming lanquage?")
                                .AddMultipleAnswers("C#", "VB", "Java Script", "Java", "Python", "Ruby")
                                .BuildQuestion();

            return question;
        }
Exemplo n.º 3
0
        private static Question CreateWhatsYourFavoriteBeer()
        {
            var questionBuilder = new QuestionBuilder();
            var question = questionBuilder
                                .WithQueryText("Whats is your favorite beer?")
                                .AddMultipleAnswers("Ariana", "Hoegaarden", "Tuborg", "Staropramen")
                                .BuildQuestion();

            return question;
        }
Exemplo n.º 4
0
        private static Question CreateWhatsYourFavoriteColor()
        {
            var questionBuilder = new QuestionBuilder();
            var question = questionBuilder
                                .WithQueryText("Whats is your favorite color?")
                                .AddMultipleAnswers("Red", "Green", "Blue", "Alpha")
                                .BuildQuestion();

            return question;
        }
        protected void ButtonSubmitQuestion_Click(object sender, EventArgs e)
        {
            ThrowExceptionIf(this.User == null, new ArgumentNullException("Unknown user"));

            var questionQueryText = this.TextBoxQueryText.Text;

            var questionAnswers = this.GetAnswerDTOsFromViewState();
            var validQuestionTexts = questionAnswers.Where(x => !string.IsNullOrEmpty(x.Text)).Select(x=>x.Text).ToArray();

            var questionBuilder = new QuestionBuilder();
            var question = questionBuilder.WithQueryText(questionQueryText)
                .AddMultipleAnswers(validQuestionTexts)
                .WithUser(this.CurrentUser)
                .BuildQuestion();

            this.DbContext.Add(question);
            this.DbContext.SaveChanges();

            string newlyCreateQuestionPageUrl = string.Format("~/ShowVotingResults?questionId={0}", question.Id);
            Response.Redirect(newlyCreateQuestionPageUrl);
        }