예제 #1
0
        public long CreateNewAirline(LoginToken <Administrator> token, AirlineCompany airline)
        {
            long newId = 0;

            if (UserIsValid(token))
            {
                newId = _airlineDAO.Add(airline);
            }
            return(newId);
        }
        public void Remove(AirlineCompany t)
        {
            using (SqlConnection connection = new SqlConnection(FlightCenterConfig.CONNECTION_STRING))
            {
                SqlCommand cmd = new SqlCommand("REMOVE_AIRLINE_COMPANY", connection);
                cmd.Parameters.Add(new SqlParameter("@ID", t.AirlineName));
                connection.Open();
                cmd.CommandType = CommandType.StoredProcedure;


                SqlDataReader reader = cmd.ExecuteReader(System.Data.CommandBehavior.Default);
                cmd.Connection.Close();
            }
        }
        public void Update(AirlineCompany t)
        {
            using (SqlConnection connection = new SqlConnection(FlightCenterConfig.CONNECTION_STRING))
            {
                SqlCommand cmd = new SqlCommand("UPDATE_AIRLINE_COMPANY", connection);
                cmd.Parameters.Add(new SqlParameter("@ID", t.ID));
                cmd.Parameters.Add(new SqlParameter("@AIRLINE_NAME", t.AirlineName));
                cmd.Parameters.Add(new SqlParameter("@USER_NAME", t.UserName));
                cmd.Parameters.Add(new SqlParameter("@PASSWOED", t.Password));
                cmd.Parameters.Add(new SqlParameter("@COUNTRY_CODE", t.CountryCode));
                connection.Open();
                cmd.CommandType = CommandType.StoredProcedure;

                SqlDataReader reader = cmd.ExecuteReader(System.Data.CommandBehavior.Default);
                cmd.Connection.Close();
            }
        }
예제 #4
0
        public bool TryAirlineLogin(string username, string password, out LoginToken <AirlineCompany> token)
        {
            _airlineDAO = new AirlineDAOMSSQL();
            AirlineCompany company = _airlineDAO.GetAirLineByUserName(username);

            if (company != null)
            {
                if (company.Password == password)
                {
                    token = new LoginToken <AirlineCompany>()
                    {
                        User = company
                    };
                    return(true);
                }
            }
            else
            {
                try
                {
                    if (company == null)
                    {
                        token = null;
                        return(false);
                    }
                }
                catch (WrongPasswordException)
                {
                    token = new LoginToken <AirlineCompany>()
                    {
                        User = company
                    };
                    return(false);

                    throw new WrongPasswordException("Your Password is not correct, Try again");
                }
            }
            token = null;

            return(false);
        }
        public long Add(AirlineCompany t)
        {
            long newId = 0;

            using (SqlConnection connection = new SqlConnection(FlightCenterConfig.CONNECTION_STRING))
            {
                using (SqlCommand cmd = new SqlCommand("ADD_NEW_AIRLINECOMPANY", connection))
                {
                    connection.Open();
                    cmd.Parameters.Add(new SqlParameter("@AIRLINE_NAME", t.AirlineName));
                    cmd.Parameters.Add(new SqlParameter("@USER_NAME", t.UserName));
                    cmd.Parameters.Add(new SqlParameter("@PASSWORD", t.Password));
                    cmd.Parameters.Add(new SqlParameter("@COUNTRY_CODE", t.CountryCode));

                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.ExecuteNonQuery();

                    SqlDataReader reader = cmd.ExecuteReader(CommandBehavior.Default);
                }
            }
            return(newId);
        }
예제 #6
0
 public IList <Flight> GetFlightsByAirlineCompany(AirlineCompany airline)
 {
     throw new NotImplementedException();
 }
예제 #7
0
        public override bool Equals(object obj)
        {
            AirlineCompany otherairlineCompany = obj as AirlineCompany;

            return(this.ID == otherairlineCompany.ID);
        }