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