private void button1_Click(object sender, EventArgs e) { if (listBox1.SelectedItem != null) { RentService.AddNewRent(new RentClass(client, (CarClass)listBox1.SelectedItem)); MessageBox.Show($"Car with id {((CarClass)listBox1.SelectedItem).CarId} was successfully rented", "Autopark"); this.Close(); } }
private static void RentCar(ClientClass client) { Console.Clear(); //AutoParkService.PrintAvailableCars(); CarClass chosenCar = AutoParkService.ChooseCar(); Console.Clear(); if (chosenCar != null) { RentService.AddNewRent(new RentClass(client, chosenCar)); Console.WriteLine("Car with id '{0}' was successfully rented.", chosenCar.CarId); } else { Console.WriteLine("Id not found!"); } }