public bool SignInFunction(AspnetUserVMModel vmModel)//sign in method
        {
            bool isSignIn = false;

            try
            {
                var record = (from a in _db.AspNetUsers
                              where a.Name == vmModel.Name && a.Password == vmModel.Password
                              select a).Count() > 0 ? true : false;
                if (record)
                {
                    isSignIn = true;
                }
            }
            catch (Exception ex)
            {
            }
            return(isSignIn);
        }
示例#2
0
        protected void signInBtn_Click(object sender, EventArgs e)        //This is login method for login in the application
        {
            AspnetUserVMModel    _viewModel = new AspnetUserVMModel();    //View model instance
            IAspnetUserInterface _service   = new AspnetUserRepository(); //Service class instance

            Response.Cookies["UserName"].Value = Username.Text.Trim();
            Response.Cookies["Password"].Value = password.Text.Trim();
            _viewModel.Name     = Username.Text.Trim();
            _viewModel.Password = password.Text.Trim();
            bool msg = _service.SignInFunction(_viewModel);//Sign in method calling

            if (msg)
            {
                Response.Redirect("Default.aspx");
            }
            else
            {
                Label1.Visible = true;
                Label1.Text    = "Login ID and Password is invalid.";
            }
        }