private void Button_Add_Car_Click(object sender, RoutedEventArgs e) { CarDTO newCar = new CarDTO(); EditCarWindow dialog = new EditCarWindow(newCar, false); var result = dialog.ShowDialog(); if (result == true) { var transport = (TransportDTO)cBoxTransport.SelectedItem; transportService.AddCarToTransport(transport.TransportId, newCar); dialog.Close(); UpdateControls(); } }
private void Button_Edit_Car_Click(object sender, RoutedEventArgs e) { if (lbCars.SelectedItem != null) { CarDTO editedCar = lbCars.SelectedItem as CarDTO; EditCarWindow dialog = new EditCarWindow(editedCar, true); var result = dialog.ShowDialog(); if (result == true) { var transport = (TransportDTO)cBoxTransport.SelectedItem; transportService.UpdateCar(transport.TransportId, editedCar); dialog.Close(); UpdateControls(); } } else { MessageBox.Show("Выберите транспорт для изменения", "Маленькая ошибочка!", MessageBoxButton.OK, MessageBoxImage.Information); } }