public void AddAdditionalChoice(BaseAnswerModel data)
        {
            var optionChoices    = _optionChoiceService.GetListByOptionGroup(data.OptionGroupId, true).Result;
            var optionChoice     = optionChoices.Where(x => x.IsAdditionalChoise == true).FirstOrDefault();
            var questionOptionId = _questionOptionService.Add(data.Id, Guid.Parse(optionChoice.Id));

            Answers answer = new Answers()
            {
                AnswerBoolean    = false,
                AnswerDateTime   = null,
                AnswerNumeric    = null,
                AnswerText       = data.AdditionalAnswer,
                RespondentId     = respondentId,
                QuestionOptionId = questionOptionId
            };
            var answerId = AddAsync(answer).Result;
        }
Exemplo n.º 2
0
        private void SaveRadioQuestion(RadioQuestionModel data)
        {
            Guid          optionGroupId = _optionGroupService.AddAsync(optionGroupDefinitions.radio).Result;
            InputTypesDto type          = inputTypeList.Where(item => item.Name == data.ControlType).FirstOrDefault();
            var           questionId    = SaveQuestion(data, false, optionGroupId, type.Id, null).Result;

            if (data.Options.Count() > 0)
            {
                _optionChoiceService.AddRange(optionGroupId, data.Options);
            }

            if (data.IsAdditionalAnswer)
            {
                ItemModel item = new ItemModel()
                {
                    IsAdditionalChoise = true,
                    Value = "Additional answer radio"
                };
                var excistAdditional = _optionChoiceService.GetListByOptionGroup(optionGroupId).Result.Where(x => x.IsAdditionalChoise == true).FirstOrDefault();
                if (excistAdditional == null)
                {
                    _optionChoiceService.AddAsync(optionGroupId, item, true);
                }
            }
        }