public void Add() { if (selectedMotorbike.passengers.Count != selectedMotorbike.maximumPassengers) { Passenger passengerToAdd = new Passenger(); Console.WriteLine("Add passenger"); Console.Write("First name: "); passengerToAdd.firstName = Console.ReadLine(); Console.Write("Last name: "); passengerToAdd.lastName = Console.ReadLine(); selectedMotorbike.passengers.Add(passengerToAdd); selectedMotorbike = motorbikeServiceObj.Update(selectedMotorbike); } else { Console.WriteLine("This vehicle is full"); } }
private void submitButton_Click(object sender, System.EventArgs e) { motorbikeToEdit.vehicleName = vehicleNameTextBox.Text; motorbikeToEdit.numberPlate = numberPlateTextBox.Text; motorbikeToEdit.weight.kilograms = Convert.ToDecimal(weightTextBox.Text); motorbikeToEdit.sideCar = sideCarCheckBox.Checked; motorbikeToEdit.maximumPassengers = Convert.ToInt32(maxPassengersTextBox.Text); motorbikeToEdit.maximumFuel.litres = Convert.ToDecimal(maxFuelTextBox.Text); motorbikeToEdit.milage.milesPerGallon = Convert.ToDecimal(milageTextBox.Text); motorbikeServicesObj.Update(motorbikeToEdit); Close(); (Owner as MotorbikeFormView).FillMotorbikeList(); }
public void Select(Motorbike selectedMotorbike) { bool exit = false; while (!exit) { Console.WriteLine("\nSelected Motorbike:"); PrintInfo(selectedMotorbike, false); Console.WriteLine("Choose an option:"); Console.WriteLine("\t1. Edit"); Console.WriteLine("\t2. Delete"); Console.WriteLine("\t3. Calculate fuel"); Console.WriteLine("\t4. Refuel"); Console.WriteLine("\t5. Passengers"); Console.WriteLine("\t6. Back"); switch (Console.ReadKey(true).KeyChar) { case '1': MotorbikeEditConsoleView motorbikeEditConsoleView = new MotorbikeEditConsoleView(selectedMotorbike); selectedMotorbike = motorbikeServicesObj.Update(motorbikeEditConsoleView.Load()); break; case '2': Console.Write("Type vehicle name to confirm:"); if (Console.ReadLine() == selectedMotorbike.vehicleName) { motorbikeServicesObj.Delete(selectedMotorbike); exit = true; } else { Console.WriteLine("Cancelled"); } break; case '3': Console.Write("Enter distance in miles: "); Distance distance = new Distance(); distance.miles = Convert.ToDecimal(Console.ReadLine()); selectedMotorbike = motorbikeServicesObj.CalculateFuel(selectedMotorbike, distance); break; case '4': selectedMotorbike = motorbikeServicesObj.Refuel(selectedMotorbike); break; case '5': MotorbikePassengerConsoleView motorbikePassengers = new MotorbikePassengerConsoleView(selectedMotorbike); motorbikePassengers.Load(); break; case '6': exit = true; break; default: Console.WriteLine("Invalid input"); break; } } }
private void PassengerMotorbikeFormView_FormClosed(object sender, FormClosedEventArgs e) { motorbikeServicesObj.Update(motorbikeToEdit); (Owner as MotorbikeFormView).FillMotorbikeList(); }