Exemplo n.º 1
0
        public void CheackRoleTest()
        {
            string username = "******";
            string password = "******";

            string actual    = "U";
            string predicted = aUserBusinessLogic.CheackRole(username, password);

            Assert.AreEqual(actual, predicted);
        }
Exemplo n.º 2
0
        protected void logInButton_Click(object sender, EventArgs e)
        {
            string userName = userNameTextBox.Text;
            string password = passwordTextBox.Text;

            bool   isUserNameExist = aUserBusinessLogic.IsUserExist(userName, password);
            string userType        = aUserBusinessLogic.CheackRole(userName, password);

            if (isUserNameExist)
            {
                if (rememberCheckBox.Checked)
                {
                    Response.Cookies["UserName"].Value = userNameTextBox.Text;
                    Response.Cookies["Password"].Value = passwordTextBox.Text;

                    Response.Cookies["UserName"].Expires = DateTime.Now.AddDays(15);
                    Response.Cookies["Password"].Expires = DateTime.Now.AddDays(15);
                }
                else
                {
                    Response.Cookies["UserName"].Expires = DateTime.Now.AddDays(-1);
                    Response.Cookies["Password"].Expires = DateTime.Now.AddDays(-1);
                }

                if (userType == "U")
                {
                    Session["UserName"] = userNameTextBox.Text;
                    Response.Redirect("UserHome.aspx");
                }
                if (userType == "A")
                {
                    Session["UserName"] = userNameTextBox.Text;
                    Response.Redirect("Admin.aspx");
                }
            }
            else
            {
                lblError.Text = "Invalid User Name or Password";
            }
        }