Ejemplo n.º 1
0
        /// <summary>
        /// Get flights by origin country from the data base
        /// </summary>
        /// <param name="countryCode"></param>
        /// <returns></returns>
        public IList <FlightRazor> GetFlightsByOriginCountryAndDestination(long origin, long destination)
        {
            List <FlightRazor> flights = new List <FlightRazor>();

            using (SqlConnection conn = new SqlConnection(FlyingCenterConfig.ConString))
            {
                SqlCommand cmd = new SqlCommand("GET_FLIGHTS_BY_ORIGIN_COUNTRY_AND_DESTINATION_COUNTRY_ID", conn);
                cmd.Parameters.Add(new SqlParameter("@ORIGIN_COUNTRY_CODE", origin));
                cmd.Parameters.Add(new SqlParameter("@DESTINATION_COUNTRY_CODE", destination));
                cmd.Connection.Open();
                cmd.CommandType = CommandType.StoredProcedure;

                SqlDataReader reader = cmd.ExecuteReader(CommandBehavior.Default);

                while (reader.Read() == true)
                {
                    FlightRazor flight = new FlightRazor
                    {
                        ID                     = (Int64)reader["ID"],
                        AirlineName            = (string)reader["AIRLINE_NAME"],
                        AirlineNameAndFlightID = $"{(string)reader["AIRLINE_NAME"]} {(Int64)reader["ID"]}",
                        OriginCountry          = (string)reader["ORIGIN_COUNTRY"],
                        DestinationCountry     = (string)reader["DEST_COUNTRY"],
                        RemainingTickets       = (int)reader["REMAINING_TICKETS"],
                        DepartureTime          = (DateTime)reader["DEPARTURE_TIME_DATE_TIME"]
                    };
                    flights.Add(flight);
                }


                return(flights);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Get all flights that will land in the upcoming 12 hours or landed in the last 4 hours
        /// </summary>
        /// <returns></returns>
        public IList <FlightRazor> LandingFlights()
        {
            List <FlightRazor> flightsResults = new List <FlightRazor>();

            using (SqlConnection conn = new SqlConnection(FlyingCenterConfig.ConString))
            {
                SqlCommand cmd = new SqlCommand("RAZOR_LANDING_FLIGHTS", conn);
                cmd.Connection.Open();
                cmd.CommandType = CommandType.StoredProcedure;

                SqlDataReader reader = cmd.ExecuteReader(CommandBehavior.Default);

                while (reader.Read() == true)
                {
                    FlightRazor flight = new FlightRazor
                    {
                        ID                     = (Int64)reader["ID"],
                        AirlineName            = (string)reader["AIRLINE_NAME"],
                        AirlineNameAndFlightID = $"{(string)reader["AIRLINE_NAME"]} {(Int64)reader["ID"]}",
                        OriginCountry          = (string)reader["ORIGIN_COUNTRY"],
                        DestinationCountry     = (string)reader["DEST_COUNTRY"],
                        RemainingTickets       = (int)reader["REMAINING_TICKETS"],
                        LandingTime            = (DateTime)reader["LANDING_TIME_DATE_TIME"]
                    };
                    //flight.Airline_Pic = $"Src/Images/Logos/{flight.AirlineName}.png";

                    flightsResults.Add(flight);
                }


                return(flightsResults);
            }
        }