Ejemplo n.º 1
0
        /// <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);
        }
Ejemplo n.º 2
0
        /// <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);
        }
Ejemplo n.º 3
0
 public List <Ferry> GetAllFerries() // Weeee
 {
     return(FerryHandler.GetAllFerries());
 }
Ejemplo n.º 4
0
 public bool DeleteFerry(Ferry ferry)
 {
     return(FerryHandler.DeleteFerry(ferry));
 }
Ejemplo n.º 5
0
 public Ferry CreateFerry(Ferry ferry)
 {
     return(FerryHandler.CreateFerry(ferry));
 }
Ejemplo n.º 6
0
 public Ferry UpdateFerry(Ferry ferry)
 {
     return(FerryHandler.UpdateFerry(ferry));
 }
Ejemplo n.º 7
0
 public Ferry GetFerry(int ferryId)
 {
     return(FerryHandler.GetFerry(ferryId));
 }