/// <summary> /// /// </summary> /// <param name="tripId"></param> /// <returns></returns> public static Trip GetTrip(int tripId) { Trip trip = null; DBUtility.HandleConnection((MySqlCommand command) => { command.CommandText = "SELECT * FROM trips WHERE id = @id;"; command.Parameters.AddWithValue("@id", tripId); using (MySqlDataReader reader = command.ExecuteReader()) { if (reader.Read()) { trip = new Trip() { TripId = reader.GetInt32("id"), DepatureTime = reader.GetDateTime("departure_time"), Ferry = FerryHandler.GetFerry(reader.GetInt32("ferry_id")), Route = RouteHandler.GetRoute(reader.GetInt32("route_id")), TripPrice = reader.GetDouble("price") // Possible loss of precision, use decimal instead }; } } }); return(trip); }
/// <summary> /// /// </summary> /// <returns></returns> public static List <Trip> GetAllTrips() { List <Trip> trips = new List <Trip>(); DBUtility.HandleConnection((MySqlCommand command) => { command.CommandText = "SELECT * FROM trips;"; using (MySqlDataReader reader = command.ExecuteReader()) { if (reader.Read()) { trips.Add(new Trip() { TripId = reader.GetInt32("id"), DepatureTime = reader.GetDateTime("departure_time"), Ferry = FerryHandler.GetFerry(reader.GetInt32("ferry_id")), Route = RouteHandler.GetRoute(reader.GetInt32("route_id")), TripPrice = reader.GetDouble("price") // Possible loss of precision, use decimal instead }); } } }); return(trips); }
public List <Ferry> GetAllFerries() // Weeee { return(FerryHandler.GetAllFerries()); }
public bool DeleteFerry(Ferry ferry) { return(FerryHandler.DeleteFerry(ferry)); }
public Ferry CreateFerry(Ferry ferry) { return(FerryHandler.CreateFerry(ferry)); }
public Ferry UpdateFerry(Ferry ferry) { return(FerryHandler.UpdateFerry(ferry)); }
public Ferry GetFerry(int ferryId) { return(FerryHandler.GetFerry(ferryId)); }