public void SearchJoke() { FavouriteJokesToBeSearched.Clear(); FavouriteJokesToBeSearched.AddRange(_jokeWorkflow.GetAllFavouriteJokes().AsEnumerable()); if (!string.IsNullOrWhiteSpace(SearchText)) { var firstPartResult = FavouriteJokesToBeSearched.Where(x => x.FirstPart.ToLower().Contains(SearchText.ToLower().Trim())); var secondPartResult = FavouriteJokesToBeSearched.Where(x => x.SecondPart != null).Where(x => x.SecondPart.ToLower().Contains(SearchText.ToLower().Trim())); FavouriteJokes.Clear(); FavouriteJokes.AddRange(firstPartResult); FavouriteJokes.AddRange(secondPartResult); GetJoke(); GetAllFavouriteJokes(); SavePreviousJoke(); } }
//Private methods private void GetAllFavouriteJokes() { var jokeUiModels = _jokeWorkflow.GetAllFavouriteJokes().AsEnumerable(); FavouriteJokes.Clear(); FavouriteJokes.AddRange(jokeUiModels); }