Exemple #1
0
 public Flight(long id, long airline_Company_Id, long origin_Country_Id, long destination_Country_Id, DateTime departure_Time,
               DateTime landing_Time, int remaining_Tickets, AirlineCompany airline_Company)
 {
     Id = id;
     Airline_Company_Id     = airline_Company_Id;
     Origin_Country_Id      = origin_Country_Id;
     Destination_Country_Id = destination_Country_Id;
     Departure_Time         = departure_Time;
     Landing_Time           = landing_Time;
     Remaining_Tickets      = remaining_Tickets;
     Airline_Company        = airline_Company;
 }
 public void Update(AirlineCompany t)
 {
     try
     {
         RunSpNonExecute(AppConfig.Instance.ConnectionString, "sp_update_airline", new NpgsqlParameter[]
         {
             new NpgsqlParameter("_id", t.Id),
             new NpgsqlParameter("_name", t.Name),
             new NpgsqlParameter("_country_id", t.Country_Id),
             new NpgsqlParameter("_user_id", t.User_Id)
         });
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
 }
Exemple #3
0
        public IList <AirlineCompany> GetAllWaitingAirlines()
        {
            List <AirlineCompany> airline_companies = new List <AirlineCompany>();

            try
            {
                using (var conn = new NpgsqlConnection(AppConfig.Instance.ConnectionString))
                {
                    conn.Open();

                    NpgsqlCommand command = new NpgsqlCommand("sp_get_all_waiting_airlines", conn);
                    command.CommandType = System.Data.CommandType.StoredProcedure;
                    var reader = command.ExecuteReader();
                    while (reader.Read())
                    {
                        AirlineCompany airlineCompany = new AirlineCompany
                        {
                            Id         = (long)reader["id"],
                            Name       = reader["airline_name"].ToString(),
                            Country_Id = (long)reader["country_id"],
                            User       = new User
                            {
                                User_Name = reader["username"].ToString(),
                                Password  = reader["password"].ToString(),
                                Email     = reader["email"].ToString()
                            }
                        };
                        airline_companies.Add(airlineCompany);
                    }
                }
            }
            catch (Exception ex)
            {
                log.Error($"Could not get all waiting airlines: {ex.Message}");
            }
            return(airline_companies);
        }
        private List <AirlineCompany> GetAirlineCompanies(string conn_string, string sp_name, NpgsqlParameter[] parameters)
        {
            List <AirlineCompany> airline_companies = new List <AirlineCompany>();

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

                    NpgsqlCommand command = new NpgsqlCommand(sp_name, conn);
                    command.CommandType = System.Data.CommandType.StoredProcedure;

                    command.Parameters.AddRange(parameters);

                    var reader = command.ExecuteReader();
                    while (reader.Read())
                    {
                        AirlineCompany airlineCompany = new AirlineCompany
                        {
                            Id         = (long)reader["id"],
                            Name       = reader["name"].ToString(),
                            Country_Id = (long)reader["country_id"],
                            User_Id    = (long)reader["user_id"],
                            User       = user.Get((long)reader["user_id"])
                        };
                        airline_companies.Add(airlineCompany);
                    }
                }
            }
            catch (Exception ex)
            {
                log.Error($"Could not run {sp_name} procedure: {ex.Message}");
            }
            return(airline_companies);
        }