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