private IList <QuestionChoice> LoadQuestionChoices(Question question) { var questionChoices = new List <QuestionChoice>(); var choices = question.AnswerChoices.OrderBy(x => x.AnswerChoiceId).ToList(); List <Response> responses = question.Responses.ToList(); /* Take care of checkbox, radiobutton, and dropdownlist type response */ foreach (var choice in choices) { var result = responses.Where(x => x.QuestionId == choice.QuestionId && x.Value == choice.DisplayText && x.QuestionnaireId == Questionnaire.QuestionnaireId) .Select(x => new { x.IsSelected, x.Comment }).FirstOrDefault(); var qc = new QuestionChoice(); if (result != null) { qc.Comment = result.Comment; qc.SelectedInd = result.IsSelected; } qc.IsRequired = choice.Question.IsRequired; qc.DisplayText = choice.DisplayText; qc.Identifier = choice.AnswerChoiceId; questionChoices.Add(qc); } return(questionChoices); }
private IList<QuestionChoice> LoadQuestionChoices(Question question) { var questionChoices = new List<QuestionChoice>(); var choices = question.AnswerChoices.OrderBy(x => x.AnswerChoiceId).ToList(); List<Response> responses = question.Responses.ToList(); /* Take care of checkbox, radiobutton, and dropdownlist type response */ foreach (var choice in choices) { var result = responses.Where(x => x.QuestionId == choice.QuestionId && x.Value == choice.DisplayText && x.QuestionnaireId == Questionnaire.QuestionnaireId) .Select(x => new { x.IsSelected, x.Comment }).FirstOrDefault(); var qc = new QuestionChoice(); if (result != null) { qc.Comment = result.Comment; qc.SelectedInd = result.IsSelected; } qc.IsRequired = choice.Question.IsRequired; qc.DisplayText = choice.DisplayText; qc.Identifier = choice.AnswerChoiceId; questionChoices.Add(qc); } return questionChoices; }