private void InitProperties()
        {
            if (!Page.IsPostBack)
            {
                return;
            }

            if (!String.IsNullOrEmpty(Page.Request["poll_question"]))
            {
                Name = Page.Request["poll_question"];
            }

            try
            {
                Singleton = (Convert.ToInt32(Page.Request["questiontype"]) == 1);
            }
            catch
            {
                Singleton = true;
            }

            AnswerVariants.Clear();
            for (var i = 1; i < 20; i++)
            {
                if (String.IsNullOrEmpty(Page.Request["q" + i]))
                {
                    continue;
                }

                var id = Page.Request["qid_" + i] ?? "";
                AnswerVariants.Add(new AnswerViarint {
                    ID = id, Name = Page.Request["q" + i]
                });
            }
        }
Example #2
0
        private static ICollection <AnswerVariants> MapAnswerVariants(ICollection <AnswerOut> answerVariantsToCreate, Guid questionId)
        {
            try
            {
                var answers = new List <AnswerVariants>();
                foreach (var answerToCreate in answerVariantsToCreate)
                {
                    var answerGuid = Guid.NewGuid();
                    var answer     = new AnswerVariants
                    {
                        AnswerVariantId   = answerGuid,
                        AnswerVariantName = answerToCreate.AnswerVariantName,
                        QuestionId        = questionId
                    };

                    answers.Add(answer);
                }
                return(answers);
            }
            catch
            {
                throw;
            }
        }