Пример #1
0
        /// <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);
        }
Пример #2
0
        /// <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);
        }
Пример #3
0
 public List <Vehicle> GetAllVehicles()
 {
     return(VehicleHandler.GetAllVehicles());
 }
Пример #4
0
 public bool DeleteVehicle(Vehicle vehicle)
 {
     return(VehicleHandler.DeleteVehicle(vehicle));
 }
Пример #5
0
 public Vehicle CreateVehicle(Vehicle vehicle)
 {
     return(VehicleHandler.CreateVehicle(vehicle));
 }
Пример #6
0
 public Vehicle UpdateVehicle(Vehicle vehicle)
 {
     return(VehicleHandler.UpdateVehicle(vehicle));
 }
Пример #7
0
 public Vehicle GetVehicle(int vehicleId)
 {
     return(VehicleHandler.GetVehicle(vehicleId));
 }