public bool ValidateCredentials(LoginProps pr)
        {
            var rec = (from a in _db.Logins
                       where a.Username == pr.Username &&
                       a.Password == pr.Password
                       select a).Count() > 0 ? true : false;

            if (rec)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        protected void Login(object sender, EventArgs e)    //This is login method
        {
            LoginProps   viewProperty  = new LoginProps();  //Properties class instance
            ILoginLogics _loginService = new LoginLogics(); //Service class instance

            Response.Cookies["UserName"].Value = Username.Text.Trim();
            Response.Cookies["Password"].Value = password.Text.Trim();
            viewProperty.Username = Username.Text.Trim();
            viewProperty.Password = password.Text.Trim();
            bool msg = _loginService.ValidateCredentials(viewProperty);

            if (msg)
            {
                Response.Redirect("Coach.aspx");
            }
            else
            {
                Label1.Visible = true;
                Label1.Text    = "Login ID and Password is invalid.";
            }
        }
Exemple #3
0
        protected void btn2_Click(object sender, EventArgs e)
        {
            System.Diagnostics.Debug.WriteLine("### LOGIN BUTTON CLIKCED  ###");
            string username = txt1.Text;
            string password = txt2.Text;

            if (string.IsNullOrEmpty(username) || string.IsNullOrEmpty(password))
            {
            }
            else
            {
                login_BLL_OBJ = new LoginBLL();

                login_PROPS_OBJ          = new LoginProps();
                login_PROPS_OBJ.Username = username;
                login_PROPS_OBJ.Password = password;
                int access_level = login_BLL_OBJ.VALIDATE_USER_BLL(login_PROPS_OBJ);
                if (access_level == 1)
                {
                    System.Diagnostics.Debug.WriteLine("### USER VALIDATED  ###");
                    Session["username"] = username;
                    Session["password"] = password;
                    Response.Redirect("~/Admin.aspx");

                    //  Response.Write("<script>alert('You Have been Successfully Resgistered ')</script>");
                }
                else if (access_level == 0)
                {
                    Response.Redirect("~/User.aspx");
                }
                else
                {
                    System.Diagnostics.Debug.WriteLine("### USER NOT  VALIDATED  ###");
                }
            }
        }