private void ButtonRemoveBooking_OnClick(object sender, RoutedEventArgs e) { var booking = (AnimalBooking)ListBoxCurrentBookings.SelectedItem; DataAccessZoo dataAccess = new DataAccessZoo(); try { dataAccess.RemoveBooking(booking.BookingId); MessageBox.Show("Bokningen borttagen!"); UpdateCurrentBookingsListBox(); } catch (Exception exception) { MessageBox.Show(exception.Message); } }
private void ButtonRemoveBookingAndCloseWindow_OnClick(object sender, RoutedEventArgs e) { if (ListBoxBookings.SelectedItem != null) { DataAccessZoo dataAccess = new DataAccessZoo(); var booking = (AnimalBooking)ListBoxBookings.SelectedItem; try { dataAccess.RemoveBooking(booking.BookingId); MessageBox.Show("Mötet avslutat!"); this.Close(); } catch (DbObjectNotFoundException exception) { MessageBox.Show(exception.Message); } } }