Пример #1
0
        public void TestMethodEditInfo()
        {
            DALUserInfo userInfo = new DALUserInfo();

            int    expectedUserID     = 30;
            String expectedFullname   = "Test Edit";
            String expectedAddress    = "testE";
            String expectedPostalCode = "testE";
            String expectedCity       = "testE";
            String expectedProvince   = "te";
            String expectedCountry    = "testE";

            int userID = userInfo.EditInfo(expectedUserID, expectedFullname, expectedAddress,
                                           expectedPostalCode, expectedCity, expectedProvince, expectedCountry);

            int actualUserID = userInfo.GetInfo(expectedUserID);

            String actualFullname   = userInfo.userFullname;
            String actualAddress    = userInfo.userAddress;
            String actualPostalCode = userInfo.userPostalCode;
            String actualCity       = userInfo.userCity;
            String actualProvince   = userInfo.userProvince;
            String actualCountry    = userInfo.userCountry;

            Assert.AreEqual(expectedFullname, actualFullname);
            Assert.AreEqual(expectedAddress, actualAddress);
            Assert.AreEqual(expectedPostalCode, actualPostalCode);
            Assert.AreEqual(expectedCity, actualCity);
            Assert.AreEqual(expectedProvince, actualProvince);
            Assert.AreEqual(expectedCountry, actualCountry);
        }
        public Boolean LogIn(string loginName, string passWord)
        {
            UserID = -1;

            if ((loginName != "") && (passWord != ""))
            {
                var dbUser = new DALUserInfo();
                UserID = dbUser.LogIn(loginName, passWord);
                if (UserID > 0)
                {
                    LoginName = loginName;
                    Password  = passWord;
                    FullName  = dbUser.GetName(loginName, passWord);
                    LoggedIn  = true;
                    return(true);
                }
                else
                {
                    MessageString = dbUser.ErrorMessage;
                    LoggedIn      = false;
                    return(false);
                }
            }
            else
            {
                MessageString = "Please fill in all slots.";
                LoggedIn      = false;
                return(false);
            }
        }
Пример #3
0
        public Boolean checkUserName(string username)
        {
            var dbUser = new DALUserInfo();

            if (dbUser.validateUserName(username))
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #4
0
        public Boolean SetPass(String newPass, int userID)
        {
            var dbUser    = new DALUserInfo();
            int retUserId = dbUser.setPass(newPass, userID);

            if (retUserId > 0)
            {
                return(true);
            }
            else
            {
                return(true);
            }
        }
Пример #5
0
        public Boolean GetPass(int userid)
        {
            var dbUser    = new DALUserInfo();
            int retUserId = dbUser.GetPass(userid);

            if (retUserId > 0)
            {
                userPassword = dbUser.userPassword;
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #6
0
        public bool LogIn(string loginname, string password)
        {
            var dbUser = new DALUserInfo();

            UserID = dbUser.LogIn(loginname, password);

            if (UserID > 0)
            {
                LoginName = loginname;
                Password  = password;
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #7
0
        public Boolean LogIn(string loginName, string passWord)
        {
            var dbUser = new DALUserInfo();

            UserID = dbUser.LogIn(loginName, passWord);
            if (UserID > 0)
            {
                LoginName = loginName;
                Password  = passWord;
                LoggedIn  = true;
                return(true);
            }
            else
            {
                ErrorMessage = dbUser.ErrorMessage;
                LoggedIn     = false;
                return(false);
            }
        }
Пример #8
0
        public Boolean CreateProfile(String username, String password, String fullname, String address, String postalCode, String city, String province, String country)
        {
            var dbUser    = new DALUserInfo();
            int retUserId = dbUser.CreateProfile(username, password, fullname, address, postalCode, city, province, country);

            if (retUserId > 0)
            {
                LoginName = username;
                Password  = password;
                FullName  = fullname;
                UserID    = retUserId;
                Address   = address;
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #9
0
        public Boolean GetInfo(int userid)
        {
            var dbUser    = new DALUserInfo();
            int retUserId = dbUser.GetInfo(userid);

            if (retUserId > 0)
            {
                Address    = dbUser.userAddress;
                FullName   = dbUser.userFullname;
                PostalCode = dbUser.userPostalCode;
                City       = dbUser.userCity;
                Province   = dbUser.userProvince;
                Country    = dbUser.userCountry;
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #10
0
        public Boolean EditInfo(int userid, string fullName, string address, string postalCode, string city, string province, string country)
        {
            var dbUser    = new DALUserInfo();
            int retUserId = dbUser.EditInfo(userid, fullName, address, postalCode, city, province, country);

            if (retUserId > 0)
            {
                Address    = address;
                FullName   = fullName;
                PostalCode = postalCode;
                City       = city;
                Province   = province;
                Country    = country;
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #11
0
        public void TestMethodCreateProfile()
        {
            DALUserInfo userInfo = new DALUserInfo();

            String expectedUsername   = "******";
            String expectedPassword   = "******";
            String expectedFullname   = "Test Register";
            String expectedAddress    = "test";
            String expectedPostalCode = "test";
            String expectedCity       = "test";
            String expectedProvince   = "tr";
            String expectedCountry    = "test";

            int uid = userInfo.CreateProfile(expectedUsername, expectedPassword, expectedFullname,
                                             expectedAddress, expectedPostalCode, expectedCity, expectedProvince, expectedCountry);

            int    actualUserID     = userInfo.GetInfo(uid);
            String actualUsername   = userInfo.userName;
            String actualPassword   = userInfo.userPassword;
            String actualFullname   = userInfo.userFullname;
            String actualAddress    = userInfo.userAddress;
            String actualPostalCode = userInfo.userPostalCode;
            String actualCity       = userInfo.userCity;
            String actualProvince   = userInfo.userProvince;
            String actualCountry    = userInfo.userCountry;

            Assert.AreEqual(uid, actualUserID);
            Assert.AreEqual(expectedUsername, actualUsername);
            Assert.AreEqual(expectedPassword, actualPassword);
            Assert.AreEqual(expectedFullname, actualFullname);
            Assert.AreEqual(expectedAddress, actualAddress);
            Assert.AreEqual(expectedPostalCode, actualPostalCode);
            Assert.AreEqual(expectedCity, actualCity);
            Assert.AreEqual(expectedProvince, actualProvince);
            Assert.AreEqual(expectedCountry, actualCountry);

            userInfo.deleteUser(uid);
        }
Пример #12
0
        public Boolean LogIn(string loginName, string passWord)
        {
            var dbUser = new DALUserInfo();

            UserID = dbUser.LogIn(loginName, passWord);
            if (UserID > 0)
            {
                LoginName = loginName;
                Password  = passWord;
                FullName  = dbUser.DbFullName;
                if (dbUser.isManager)
                {
                    isManager = true;
                }

                return(true);
            }
            else
            {
                isManager = false; // manager is false
            }
            return(false);
        }
Пример #13
0
        public bool Register(string username, string password1, string password2, string fullName)
        {
            if (!UserRegister.VerifyRegistration(username, password1, password2, fullName))
            {
                ErrorMessage = "Please fill in all fields.";
                return(false);
            }
            if (DALUserInfo.HasInvalidPassword(password1))
            {
                ErrorMessage = "Password requires at least six alphanumeric characters.";
                return(false);
            }

            string newType = "CU";

            DBQueries db = new DBQueries();

            List <object> bookstore = new List <object>(
                new object[] { username, password1, newType, 0, fullName }
                );

            return(db.INSERT_INTO_TABLE("UserData", bookstore));
        }
Пример #14
0
        public int checkAdmin(string username)
        {
            DALUserInfo dalUser = new DALUserInfo();

            return(dalUser.checkAdmin(username));
        }