public void UpdateSearchResults(ErrorReporter errorReporter) { if (SearchQuery == null || SearchQuery.Count() < 3) { SearchResults.Clear(); errorReporter.Throw( new InvalidOperationException("Search query is null or too short"), UserErrorsViewModel.SearchQueryTooShortMessage); } var results = PaulRepository.SearchCourses(SearchQuery, _catalog).Take(searchResultCount); SearchResults.Clear(); SearchResults.AddRange(results.Select(course => { var added = _schedule.SelectedCourses.Any(s => s.CourseId == course.Id); return(new SearchResultViewModel(course, added)); })); }