public void LoadQuestions(IEnumerable <QuestionViewModel> questions) { if (!String.IsNullOrEmpty(QIds)) { var qids = QIds.SplitToIds(); Questions = questions.Where(item => qids.Contains(item.Id)).ToList(); } foreach (var item in SubItems) { item.LoadQuestions(questions); } }
public ICollection <int> GetQuestionIds() { var questionIds = new List <int>(); if (!String.IsNullOrEmpty(QIds)) { questionIds.AddRange(QIds.SplitToIds()); } if (SubItems.IsNullOrEmpty()) { return(questionIds.ToList()); } var subQids = SubItems.SelectMany(item => item.GetQuestionIds()); if (subQids.IsNullOrEmpty()) { return(questionIds.ToList()); } return(questionIds.Union(subQids).Distinct().ToList()); }