Exemple #1
0
 // save section
 private void SaveTextQuestion(TextQuestionModel data)
 {
     Guid          optionGroupId = _optionGroupService.AddAsync(optionGroupDefinitions.textBox).Result;
     InputTypesDto type          = inputTypeList.Where(item => item.Name == data.ControlType).FirstOrDefault();
     var           questionId    = SaveQuestion(data, false, optionGroupId, type.Id, null).Result;
     Guid          id            = _optionChoiceService.AddAsync(optionGroupId, null).Result;
 }
Exemple #2
0
        public BaseQuestionModel GetQuestionByType(string baseQuestion)
        {
            BaseQuestionModel baseQuestionM = JsonConvert.DeserializeObject <BaseQuestionModel>(baseQuestion);

            if (Enum.TryParse(baseQuestionM.ControlType.ToString(), out type))
            {
                switch (type)
                {
                case QuestionTypes.Textbox:
                {
                    TextQuestionModel question = JsonConvert.DeserializeObject <TextQuestionModel>(baseQuestion);
                    baseQuestionM = question as BaseQuestionModel;
                    break;
                }

                case QuestionTypes.Textarea:
                {
                    TextAreaQuestionModel question = JsonConvert.DeserializeObject <TextAreaQuestionModel>(baseQuestion);
                    baseQuestionM = question as BaseQuestionModel;
                    break;
                }

                case QuestionTypes.Radio:
                {
                    RadioQuestionModel question = JsonConvert.DeserializeObject <RadioQuestionModel>(baseQuestion);
                    baseQuestionM = question as BaseQuestionModel;
                    break;
                }

                case QuestionTypes.Checkbox:
                {
                    CheckBoxQuesstionModel question = JsonConvert.DeserializeObject <CheckBoxQuesstionModel>(baseQuestion);
                    baseQuestionM = question as BaseQuestionModel;
                    break;
                }

                case QuestionTypes.Dropdown:
                {
                    DropdownQuestionModel question = JsonConvert.DeserializeObject <DropdownQuestionModel>(baseQuestion);
                    baseQuestionM = question as BaseQuestionModel;
                    break;
                }

                case QuestionTypes.GridRadio:
                {
                    GridRadioQuestionModel question = JsonConvert.DeserializeObject <GridRadioQuestionModel>(baseQuestion);
                    baseQuestionM = question as BaseQuestionModel;

                    break;
                }
                }
            }
            return(baseQuestionM);
        }
Exemple #3
0
        private void UpdateTextQuestion(TextQuestionModel data)
        {
            var question = GetQuestionById(Guid.Parse(data.Id));

            question.Name             = data.Text;
            question.Description      = data.Description;
            question.Required         = data.Required;
            question.OrderNo          = data.Order;
            question.AdditionalAnswer = data.IsAdditionalAnswer;

            UpdateQuestion(question);
        }
Exemple #4
0
        private BaseQuestionModel GetTextQuestion(QuestionsDto questionDto, string type)
        {
            TextQuestionModel textQuestion = new TextQuestionModel()
            {
                Id                 = questionDto.Id.ToString(),
                Text               = questionDto.Name,
                Order              = questionDto.OrderNo,
                ControlType        = type,
                Description        = questionDto.Description,
                IsAdditionalAnswer = questionDto.AdditionalAnswer,
                Required           = questionDto.Required
            };

            return(textQuestion as BaseQuestionModel);
        }