Ejemplo n.º 1
0
        // Search Customer By UserName.
        public Administrator GetAdminByUserName(LoginToken <Administrator> token, string userName)
        {
            Administrator admin = null;

            if (UserIsValid(token))
            {
                admin = _adminDAO.GetByUserName(userName);
            }
            return(admin);
        }
Ejemplo n.º 2
0
        // Try To Login As Admin User.
        public bool TryAdminLogin(string userName, string password, out LoginToken <Administrator> token)
        {
            token = null;
            // Default Admin.
            if (userName.ToUpper() == FlyingCenterConfig.ADMIN_NAME)
            {
                if (password == FlyingCenterConfig.ADMIN_PASSWORD)
                {
                    token = new LoginToken <Administrator> {
                        User = new Administrator {
                            Id = 0, User_Name = FlyingCenterConfig.ADMIN_NAME, Password = FlyingCenterConfig.ADMIN_PASSWORD
                        }
                    };
                    return(true);
                }
                else
                {
                    throw new WrongPasswordException("Your Password Isn't Match To Your UserName!");
                }
            }
            //DAO Admin.
            Administrator admin = _administratorDAO.GetByUserName(userName);

            if (admin != null)
            {
                if (admin.User_Name.ToUpper() == userName.ToUpper())
                {
                    if (admin.Password.ToUpper() == password.ToUpper())
                    {
                        token = new LoginToken <Administrator> {
                            User = admin
                        };
                        return(true);
                    }
                    else
                    {
                        throw new WrongPasswordException("Your Password Isn't Match To Your UserName!");
                    }
                }
            }
            return(false);
        }