예제 #1
0
        public IList <Flights> GetFlightsByLandingDate(DateTime landingDate)
        {
            List <Flights> f_list = new List <Flights>();

            try
            {
                using (var conn = new NpgsqlConnection(GlobalConfig.GetConn))
                {
                    conn.Open();

                    using (var cmd = new NpgsqlCommand("sp_get_flights_by_landing_time", conn))
                    {
                        cmd.CommandType = System.Data.CommandType.StoredProcedure;
                        cmd.Parameters.Add(new NpgsqlParameter("l_time", landingDate));

                        var reader = cmd.ExecuteReader();
                        while (reader.Read())
                        {
                            Flights f = new Flights();
                            {
                                f.ID = (long)reader["id"];
                                f.AirlineCompanyId     = (long)reader["airline_company_id"];
                                f.OriginCountryId      = (long)reader["origin_country_id"];
                                f.DestinationCountryId = (long)reader["destination_country_id"];
                                f.DepartureTime        = (DateTime)reader["departure_time"];
                                f.LandingTime          = (DateTime)reader["landing_time"];
                                f.RemainingTickets     = (int)reader["remaining_tickets"];
                            }
                            f_list.Add(f);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                log.Error($"Something went wrong in GetFlightsByLandingDate {ex} check connection");
            }
            return(f_list);
        }
예제 #2
0
        public List <Flights> GetAll()
        {
            List <Flights> f_list = new List <Flights>();

            try
            {
                using (NpgsqlCommand cmd = new NpgsqlCommand())
                {
                    using (cmd.Connection = new NpgsqlConnection(GlobalConfig.GetConn))
                    {
                        cmd.Connection.Open();
                        cmd.CommandType = System.Data.CommandType.Text;
                        cmd.CommandText = $"select * from sp_get_all_flights()";
                        var reader = cmd.ExecuteReader();
                        while (reader.Read())
                        {
                            Flights f = new Flights();
                            {
                                f.ID = (long)reader["id"];
                                f.AirlineCompanyId     = (long)reader["airline_company_id"];
                                f.OriginCountryId      = (long)reader["origin_country_id"];
                                f.DestinationCountryId = (long)reader["destination_country_id"];
                                f.DepartureTime        = (DateTime)reader["departure_time"];
                                f.LandingTime          = (DateTime)reader["landing_time"];
                                f.RemainingTickets     = (int)reader["remaining_tickets"];
                            }
                            f_list.Add(f);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                log.Error($"Something went wrong in GetAllFlights {ex} check connection");
            }
            return(f_list);
        }
예제 #3
0
        public override bool Equals(object obj)
        {
            Flights other = (Flights)obj;

            return(this.ID == other.ID);
        }
예제 #4
0
 public void Add(Flights f)
 {
     ExecuteNonQuery($"call sp_add_flights({f.AirlineCompanyId},{f.OriginCountryId},{f.DestinationCountryId},'{f.DepartureTime}','{f.LandingTime}',{f.RemainingTickets})");
     log.Debug($"New Flight {f}");
 }
예제 #5
0
 public void Update(Flights f)
 {
     ExecuteNonQuery($"call sp_update_flights({f.ID},{f.AirlineCompanyId},{f.OriginCountryId},{f.DestinationCountryId},'{f.DepartureTime}','{f.LandingTime}',{f.RemainingTickets}");
 }