/// <summary> /// /// </summary> /// <param name="reservationId"></param> /// <returns></returns> public static Reservation ReadReservation(int reservationId) { Reservation reservation = null; DBUtility.HandleConnection((MySqlCommand command) => { command.CommandText = "SELECT * FROM reservations WHERE id = @id;"; command.Parameters.AddWithValue("@id", reservationId); using (MySqlDataReader reader = command.ExecuteReader()) { if (reader.Read()) { reservation = new Reservation() { ReservationId = reader.GetInt32("id"), Customer = CustomerHandler.GetCustomer(reader.GetInt32("customer_id")), //I made that method, is that okay? NumberOfPeople = reader.GetInt32("number_of_people"), TotalPrice = reader.GetInt32("total_price"), Trip = TripHandler.GetTrip(reader.GetInt32("trip_id")), Vehicle = VehicleHandler.GetVehicle(reader.GetInt32("vehicle_id")) }; } } }); return(reservation); }
/// <summary> /// /// </summary> /// <param name="customer"></param> /// <returns></returns> public static List <Reservation> ReadAllCustomerReservations(Customer customer) { List <Reservation> reservations = new List <Reservation>(); DBUtility.HandleConnection((MySqlCommand command) => { command.CommandText = "SELECT * FROM reservations WHERE customer_id = @customer_id;"; command.Parameters.AddWithValue("@customer_id", customer.CustomerId); using (MySqlDataReader reader = command.ExecuteReader()) { while (reader.Read()) { reservations.Add(new Reservation() { ReservationId = reader.GetInt32("id"), Customer = CustomerHandler.GetCustomer(reader.GetInt32("customer_id")), //I made that method, is that okay? NumberOfPeople = reader.GetInt32("number_of_people"), TotalPrice = reader.GetInt32("total_price"), Trip = TripHandler.GetTrip(reader.GetInt32("trip_id")), Vehicle = VehicleHandler.GetVehicle(reader.GetInt32("vehicle_id")) }); } } }); return(reservations); }
public List <Vehicle> GetAllVehicles() { return(VehicleHandler.GetAllVehicles()); }
public bool DeleteVehicle(Vehicle vehicle) { return(VehicleHandler.DeleteVehicle(vehicle)); }
public Vehicle CreateVehicle(Vehicle vehicle) { return(VehicleHandler.CreateVehicle(vehicle)); }
public Vehicle UpdateVehicle(Vehicle vehicle) { return(VehicleHandler.UpdateVehicle(vehicle)); }
public Vehicle GetVehicle(int vehicleId) { return(VehicleHandler.GetVehicle(vehicleId)); }