Exemple #1
0
        private static List <GivenAnswerViewModel> ProcessAnswers(this DynamicQuestionnaireViewModel questionnaireViewModel, ClientFieldData[] clientFieldData)
        {
            var response    = new List <GivenAnswerViewModel>();
            var dinamycForm = clientFieldData.Where(x => x.ExtraData.Any(y => y.Key == "data-persist-questionid") && !x.ExtraData.Any(y => y.Key == "data-persist-ignore"));
            var groupForm   = dinamycForm.GroupBy(x => x.ExtraData["data-persist-questionid"]);

            foreach (var group in groupForm)
            {
                string value = string.Empty;
                if (group.Count() == 1)
                {
                    var item = group.ElementAt(0);

                    var answerId = int.Parse(item.ExtraData.Single(x => x.Key == "data-persist-answerid").Value);
                    if (answerId == 0)
                    {
                        value = string.IsNullOrEmpty(item.Value) ? null : item.Value;
                    }
                    else
                    {
                        value = answerId.ToString();
                    }
                }
                else
                {
                    var selectedElements = group.Where(x => x.Value.ToUpper() == "TRUE").Select(x => x.ExtraData.Single(y => y.Key == "data-persist-answerid").Value);
                    value = string.Join(",", selectedElements);
                }

                var answer = new GivenAnswerViewModel()
                {
                    QuestionId  = int.Parse(group.Key),
                    VersionId   = questionnaireViewModel.VersionId,
                    AnswerValue = value
                };
                response.Add(answer);
            }

            return(response);
        }
 public PartialViewResult MultipleMoreMitSonstiges_Einzel(GivenAnswerViewModel beantwortung)
 {
     return(PartialView(beantwortung));
 }
 public PartialViewResult Freitext_Einzel(GivenAnswerViewModel beantwortung)
 {
     return(PartialView(beantwortung));
 }
 public PartialViewResult MultipleOne_Einzel(GivenAnswerViewModel beantwortung)
 {
     return(PartialView(beantwortung));
 }