private void saveEntry(object sender, EventArgs e) { if (titleTextBox.Text.Length > 0) { VideoGame newGame = new VideoGame { Title = titleTextBox.Text, Console = consoleTextBox.Text, Notes = notesTextBox.Text, Own = (ownCheckBox.IsChecked.HasValue ? ownCheckBox.IsChecked.Value : false), PurchaseDate = purchaseDatePicker.Value, PurchasePrice = purchasePriceTextBox.Text, PurchasePlace = purchasePlaceTextBox.Text, SellDate = sellDatePicker.Value, SellPrice = sellPriceTextBox.Text, SellPlace = sellPlaceTextBox.Text, AddOn = addOnCheckBox.IsChecked.HasValue ? addOnCheckBox.IsChecked.Value : false, Electronic = electronicCheckBox.IsChecked.HasValue ? electronicCheckBox.IsChecked.Value : false, Used = usedCheckBox.IsChecked.HasValue ? usedCheckBox.IsChecked.Value : false, Beat = beatCheckBox.IsChecked.HasValue ? beatCheckBox.IsChecked.Value : false }; App.ViewModel.AddVideoGame(newGame); if (NavigationService.CanGoBack) { NavigationService.GoBack(); } } }
public void AddVideoGame(VideoGame newGame) { db.VideoGames.InsertOnSubmit(newGame); db.SubmitChanges(); AllVideoGames.Insert(0, newGame); VideoGamesByTitle = new ObservableCollection<VideoGame>(AllVideoGames.OrderBy(v => v.Title).ThenBy(v => v.Console)); UpdateCollections(); }
public void DeleteVideoGame(VideoGame game) { db.VideoGames.DeleteOnSubmit(game); db.SubmitChanges(); AllVideoGames.Remove(game); VideoGamesByTitle.Remove(game); UpdateCollections(); }