/// <summary> /// Method which reacts to a click on the addGameButton. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void addGameButton_Click(object sender, RoutedEventArgs e) { Console.WriteLine("Processing new game.."); string tmpTitle = newGameTitle.Text; string tmpPublisher = newGamePublisher.Text; GameViewModel newGameViewModel = new GameViewModel(); if (tmpTitle.Length > 0 && tmpPublisher.Length > 0){ newGameViewModel.Title = tmpTitle; newGameViewModel.Publisher = tmpPublisher; catalogueViewModel.Add(newGameViewModel); Console.WriteLine(newGameViewModel.ToString() + " successfully added to the catalogue."); Console.WriteLine(catalogueViewModel.ToString()); } else{ Console.WriteLine("Please provide both a title and a publisher."); } }
public void Remove(GameViewModel gameViewModel) { if (GameViewModels.Contains(gameViewModel)) { GameViewModels.Remove(gameViewModel); } }
public void Add(GameViewModel gameViewModel) { if (!GameViewModels.Contains(gameViewModel)) { GameViewModels.Add(gameViewModel); } }