private async void btnTest_Click(object sender, RoutedEventArgs e) { TimeOnline.GameRoot game = null; try { game = await TheGamesDbHandler.GetGame(txbName.Text, _platformId, false, _dataModel.ScrapGuid); if (game == null || game.Games == null) { searchResult.ItemsSource = new string[0]; MessageBox.Show("Found no games"); return; } searchResult.ItemsSource = game.Games.Select(g => g.GameTitle); } catch (Exception) { } finally { if (game != null) { _dataModel.ScrapGuid = game.UserInfo.NewGuid; LiteDBHelper.Save(_dataModel); } } }
private async void btnTest_Click(object sender, RoutedEventArgs e) { TimeOnline.GameRoot game = null; if (GeneralFunctions.IsFilenameInvalid(txbName.Text)) { MessageBox.Show("Sorry Name Contains Invalid Chars!", "Error", MessageBoxButton.OK, MessageBoxImage.Exclamation); return; } try { game = await TheGamesDbHandler.GetGame(txbName.Text, _platformId, false, _dataModel.ScrapGuid); if (game == null || game.Games == null) { MessageBox.Show("Found no games"); return; } var listGames = game.Games.Select(g => g.GameTitle); MessageBox.Show($"Found {game.Games.Count()} games.\n[{string.Join("],\n[", listGames.Take(5))}]{(listGames.Count() > 5 ? "\n...\nThe result is large, please improve the game name" : "")}", "Result", MessageBoxButton.OK, MessageBoxImage.Information); } catch (Exception) { } finally { if (game != null) { _dataModel.ScrapGuid = game.UserInfo.NewGuid; LiteDBHelper.Save(_dataModel); } } }