예제 #1
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public static List <Ferry> GetAllFerries()
        {
            List <Ferry> ferries = new List <Ferry>();

            DBUtility.HandleConnection((MySqlCommand command) =>
            {
                command.CommandText = "SELECT * FROM ferries;";

                using (MySqlDataReader reader = command.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        ferries.Add(new Ferry()
                        {
                            FerryId           = reader.GetInt32("id"),
                            FerryName         = reader.GetString("name"),
                            FerrySize         = reader.GetString("size"),
                            PassengerCapacity = reader.GetInt32("passenger_capacity"),
                            VehicleCapacity   = reader.GetInt32("vehicle_capacity"),
                            Municipality      = reader.GetString("municipality"),
                            Dock = DockHandler.GetDock(reader.GetInt32("dock_id"))
                        });
                    }
                }
            });

            return(ferries);
        }
예제 #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="ferryId"></param>
        /// <returns></returns>
        public static Ferry GetFerry(int ferryId)
        {
            Ferry ferry = null;

            DBUtility.HandleConnection((MySqlCommand command) =>
            {
                command.CommandText = "SELECT * FROM ferries WHERE id = @id;";

                command.Parameters.AddWithValue("@id", ferryId);

                using (MySqlDataReader reader = command.ExecuteReader())
                {
                    if (reader.Read())
                    {
                        ferry = new Ferry()
                        {
                            FerryId           = reader.GetInt32("id"),
                            FerryName         = reader.GetString("name"),
                            FerrySize         = reader.GetString("size"),
                            PassengerCapacity = reader.GetInt32("passenger_capacity"),
                            VehicleCapacity   = reader.GetInt32("vehicle_capacity"),
                            Municipality      = reader.GetString("municipality"),
                            Dock = DockHandler.GetDock(reader.GetInt32("dock_id"))
                        };
                    }
                }
            });

            return(ferry);
        }
예제 #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="routeId"></param>
        /// <returns></returns>
        public static Route GetRoute(int routeId)
        {
            Route route = null;

            DBUtility.HandleConnection((MySqlCommand command) =>
            {
                command.CommandText = "SELECT * FROM routes WHERE id = @id;";

                command.Parameters.AddWithValue("@id", routeId);

                using (MySqlDataReader reader = command.ExecuteReader())
                {
                    if (reader.Read())
                    {
                        route = new Route()
                        {
                            Depature    = DockHandler.GetDock(reader.GetInt32("departure_dock_id")).DockName,   //This is stupid, it should be a dock object
                            Destination = DockHandler.GetDock(reader.GetInt32("destination_dock_id")).DockName, //This is stupid, it should be a dock object
                            Duration    = reader.GetInt32("duration"),
                            RouteId     = reader.GetInt32("id")
                        };
                    }
                }
            });

            return(route);
        }
예제 #4
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public static List <Route> GetAllRoutes()
        {
            List <Route> routes = new List <Route>();

            DBUtility.HandleConnection((MySqlCommand command) =>
            {
                command.CommandText = "SELECT * FROM routes;";

                using (MySqlDataReader reader = command.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        routes.Add(new Route()
                        {
                            Depature    = DockHandler.GetDock(reader.GetInt32("departure_dock_id")).DockName,   //This is stupid, it should be a dock object
                            Destination = DockHandler.GetDock(reader.GetInt32("destination_dock_id")).DockName, //This is stupid, it should be a dock object
                            Duration    = reader.GetInt32("duration"),
                            RouteId     = reader.GetInt32("id")
                        });
                    }
                }
            });

            return(routes);
        }
예제 #5
0
 public Dock GetDock(int dockId)
 {
     return(DockHandler.GetDock(dockId));
 }