Example #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);
        }
Example #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);
        }
Example #3
0
 public List <Route> GetAllRoutes()
 {
     return(RouteHandler.GetAllRoutes());
 }
 public bool DeleteRoute(Route route)
 {
     return(RouteHandler.DeleteRoute(route));
 }
 public Route CreateRoute(Route route)
 {
     return(RouteHandler.CreateRoute(route));
 }
 public Route UpdateRoute(Route route)
 {
     return(RouteHandler.UpdateRoute(route));
 }
 public Route GetRoute(int routeId)
 {
     return(RouteHandler.GetRoute(routeId));
 }