コード例 #1
0
 public void MofidyAirlineDetails(LoginToken <AirlineCompany> token, AirlineCompany airline)
 {
     if (token.User.Id == airline.Id)
     {
         _airlineDAOPGSQL.Update(airline);
     }
     else
     {
         Console.WriteLine("the id of the token and the id of the modified airline does not match");
     }
 }
コード例 #2
0
 public void RemoveAirline(LoginToken <Administrator> token, AirlineCompany airline)
 {
     if (token.User.Level > 1)
     {
         _airlineDAOPGSQL.Remove(airline);
     }
     else
     {
         Console.WriteLine("administrator level 1 cant remove airlines");
     }
 }
コード例 #3
0
 public void CreateNewAirline(LoginToken <Administrator> token, AirlineCompany airline)
 {
     if (token.User.Level > 1)
     {
         _airlineDAOPGSQL.Add(airline);
     }
     else
     {
         Console.WriteLine("administrator level 1 cant create new airlines");
     }
 }
コード例 #4
0
        public AirlineCompany GetAirlineByUserame(string name)
        {
            AirlineCompany a = new AirlineCompany();

            using (NpgsqlConnection con = new NpgsqlConnection(connection_string))
            {
                con.Open();
                NpgsqlCommand cmd = new NpgsqlCommand($"select * from get_airline_by_username('{name}')", con);
                cmd.CommandType = System.Data.CommandType.Text;
                var reader = cmd.ExecuteReader();
                while (reader.Read())
                {
                    a.Id        = (long)reader.GetValue(0);
                    a.Name      = (string)reader.GetValue(1);
                    a.CountryID = (int)reader.GetValue(2);
                    a.UserId    = (long)reader.GetValue(3);
                }
            }
            return(a);
        }
コード例 #5
0
 public void Update(AirlineCompany a)
 {
     ExecuteNonQuery($"call update_airline({a.Id},'{a.Name}', {a.CountryID}, {a.UserId})");
 }
コード例 #6
0
 public void Remove(AirlineCompany a)
 {
     ExecuteNonQuery($"call remove_airline({a.Id})");
 }
コード例 #7
0
 public void Add(AirlineCompany a)
 {
     ExecuteNonQuery($"call add_airline('{a.Name}', {a.CountryID}, {a.UserId})");
 }
コード例 #8
0
 public void UpdateAirlineDetails(LoginToken <Administrator> token, AirlineCompany airline)
 {
     _airlineDAOPGSQL.Update(airline);
 }