public void AddGame() { GameListEntry newGame = new GameListEntry(); // Create and show GameManagement view GameManagement gameManagement = new GameManagement(newGame); GameManagementViewModel viewModel = new GameManagementViewModel(gameManagement); GameManagementWindow window = new GameManagementWindow(viewModel); // Result is true if save button is pressed if (window.ShowDialog() == true) { if (_database.AddGame(newGame.ToDatabaseEntry())) { _games.Add(newGame); } else { MessageBox.Show("Failed to add game to database", "Data Error", MessageBoxButton.OK, MessageBoxImage.Error); } } }
public void EditGame(GameListEntry entry) { // Copy entry in case of user cancel GameListEntry newEntry = new GameListEntry(entry); // Create and show GameManagement view GameManagement gameManagement = new GameManagement(newEntry); GameManagementViewModel viewModel = new GameManagementViewModel(gameManagement); GameManagementWindow window = new GameManagementWindow(viewModel); // Result is true if save button is pressed if (window.ShowDialog() == true) { if (_database.EditGame(entry.Name, newEntry.ToDatabaseEntry())) { entry.Copy(newEntry); } else { MessageBox.Show("Failed to update game in database", "Data Error", MessageBoxButton.OK, MessageBoxImage.Error); } } }