private async void ButtonBase_SearchTags_OnClick(object sender, RoutedEventArgs e) { string tagToSearchFor = TextBox_Search_Tags.Text; Properties.Settings.Default.resentSearch = tagToSearchFor; Jokes foundJokes = await Task.Run(() => { Jokes derpJokes = new Jokes(); foreach (Joke joke in JokesList) { if (joke.ContainsTopic(tagToSearchFor)) { derpJokes.Add(joke); } } Thread.Sleep(3000); return derpJokes; }); if (_searchResultsWindow != null) _searchResultsWindow.Focus(); else { _searchResultsWindow = new SearchResults(foundJokes); _searchResultsWindow.Owner = this; _searchResultsWindow.WindowStartupLocation = WindowStartupLocation.CenterOwner; _searchResultsWindow.CloseEvent += SearchResultsClosed; _searchResultsWindow.Show(); } }
// Load jokes from db private async Task LoadData() { if (_isDataLoaded) { return; } _isDataLoaded = true; var jokes = await _jokeStore.GetJokesAsync(); foreach (var joke in jokes) { Jokes.Add(new JokeViewModel(joke)); } }
public async Task Search(string query) { IsBusy = true; var jokes = await _apiService.GetSearchResult(query); Jokes.Clear(); if (jokes != null) { foreach (var joke in jokes.result) { Jokes.Add(joke); } } IsBusy = false; }
private async Task Search(string query) { IsBusy = true; var jokes = await ApiService.Search(query); Jokes.Clear(); if (jokes != null) { foreach (var joke in jokes.result) { Jokes.Add(joke); } } IsBusy = false; }
// Add new JokeOfTheDay to list private void OnJOTDJokeAdded(JokeOfTheDayViewModel viewModel, Joke joke) { Jokes.Add(new JokeViewModel(joke)); SortJokesDesc(); }
// Add new joke to list private void OnJokeAdded(JokeDetailViewModel viewModel, Joke joke) { Jokes.Add(new JokeViewModel(joke)); SortJokesDesc(); }