IEnumerable<DepartmentViewModel> FindMatches(string searchText, DepartmentViewModel person) { if (person.NameContainsText(searchText)) yield return person; foreach (DepartmentViewModel child in person.Children) foreach (DepartmentViewModel match in this.FindMatches(searchText, child)) yield return match; }
private DepartmentViewModel(Department department, DepartmentViewModel parent) { _department = department; _parent = parent; _children = new ReadOnlyCollection<DepartmentViewModel>( (from child in _department.Children select new DepartmentViewModel(child, this)) .ToList<DepartmentViewModel>()); }
public FamilyTreeViewModel(Department rootPerson) { _rootPerson = new DepartmentViewModel(rootPerson); _firstGeneration = new ReadOnlyCollection<DepartmentViewModel>( new DepartmentViewModel[] { _rootPerson }); _searchCommand = new SearchFamilyTreeCommand(this); }