/// <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); }
/// <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); }
public bool CreateCustomer(Customer customer) { return(CustomerHandler.CreateCustomer(customer).CustomerId != 0); }
public Contract.dto.Customer GetCustomerByLogin(string username, string password) { return(CustomerHandler.ReadCustomer(username, password)); }
public Customer CreateCustomer(Customer customer) { return(CustomerHandler.CreateCustomer(customer)); }
public bool DeleteCustomer(Customer customer) { return(CustomerHandler.DeleteCustomer(customer)); }
Customer AdminstrationContract.GetCustomer(string mail) { return(CustomerHandler.ReadCustomer(mail)); }
List <Customer> AdminstrationContract.GetAllCustomer() { return(CustomerHandler.ReadAllCustomer()); }
public Customer UpdateCustomer(Customer customer) { return(CustomerHandler.UpdateCustomer(customer)); }