// Equals check
        public override bool Equals(object obj)
        {
            //return Equals(obj as AirlineCompany);

            if (obj == null)
            {
                return(false);
            }
            AirlineCompany a = obj as AirlineCompany;

            if (a == null)
            {
                return(false);
            }
            return(ID == a.ID);
        }
예제 #2
0
        public void UserLogin()
        {
            Console.Write("Please, input Username: "******"Please, input Password: "******"Please, contact to administrator");
            }
            while ((administrator.ID == 0 && administrator.ID == airlineCompany.ID) && (administrator.ID == 0 && administrator.ID == customer.ID))
            {
                throw new UserNotExistException("This User not exist. Create new user.");
            }
            while (administrator.ID == 0)
            {
                TryAdminLogin(username, password, out LoginToken <Administrator> token);
                return;
            }
            while (airlineCompany.ID == 0)
            {
                TryAirlineLogin(username, password, out LoginToken <AirlineCompany> token);
                return;
            }
            while (customer.ID == 0)
            {
                TryCustomerLogin(username, password, out LoginToken <Customer> token);
                return;
            }
        }
예제 #3
0
        public bool TryAirlineLogin(string userName, string password, out LoginToken <AirlineCompany> token) // Not static?
        {
            AirlineCompany company = _arilineDAO.GetAirlineByUserame(userName);

            //AirlineCompany company = _arilineDAO.GetAirlineByUserame(userName);
            //if (company != null)
            //{
            //    if (company.PASSWORD == password)
            //    {
            //        token = new LoginToken<AirlineCompany>() { User = company };
            //        return true;
            //    }

            while (company == null) //AirlineID?
            {
                try
                {
                    AirlineDAOMSSQL.AirlineLogin(company);
                    token = new LoginToken <AirlineCompany>()
                    {
                        User = company
                    };
                    Console.WriteLine("User was logged successfully");
                    return(true);


                    //ExistingAirflineUserMenu(company);
                }
                catch (AirlineCompanyDoesNotExistException)
                {
                    Console.WriteLine("This airline company does not exist.");
                    Console.WriteLine("Input correct username or type e to exit.");
                    userName = Console.ReadLine();
                    Console.WriteLine();
                    if (userName == "e")
                    {
                        break;
                    }
                    else
                    {
                        company.USER_NAME = userName;
                        continue;
                    }
                }
                catch (WrongPasswordException)
                {
                    Console.WriteLine("Incorrect password.");
                    Console.WriteLine("Input correct password or type e to exit.");
                    password = Console.ReadLine();
                    Console.WriteLine();
                    if (password == "e")
                    {
                        break;
                    }
                    else
                    {
                        company.PASSWORD = password;
                        continue;
                    }
                }
            }
            token = null;
            return(false);
        }