public ActionResult LogOn(UserLogOn user)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    using (UserLoginDbContext db = new UserLoginDbContext())
                    {
                        var v =
                            db.UserLogOns.FirstOrDefault(
                                userCheck =>
                                userCheck.Username.Equals(user.Username) && userCheck.Password.Equals(user.Password));
                        if (v != null)
                        {
                            FormsAuthentication.SetAuthCookie(user.Username, false);
                            Session["userId"]   = user.CustomerId;
                            Session["userName"] = user.Username;

                            return(RedirectToAction("Reserve", "CustomerReservation", new { area = "Customer" }));
                        }
                        else
                        {
                            Response.Write("<div id='logmess'>");

                            Response.Write("Sorry,Invalid Username and Password Combination!!.Your Username or Password or Both incorrect.If you have no account Signup first");

                            Response.Write("</div>");
                        }
                    }
                }
                catch (Exception exmException)
                {
                    Response.Write("<div id='logmess'>");

                    Response.Write(exmException.Message);

                    Response.Write("</div>");
                }
            }

            return(View());
        }
 public ActionResult PasswordReset(PasswordReset passwordReset)
 {
     if (!ModelState.IsValid)
     {
         return(View());
     }
     else
     {
         if (passwordReset != null)
         {
             UserLoginDbContext db = new UserLoginDbContext();
             var user = db.UserLogins.FirstOrDefault(x => x.UserId == passwordReset.UserId && x.SecretQuestions == passwordReset.SecretQuestions && x.Answer == passwordReset.Answer);
             return(RedirectToAction("PasswordUpdate", new { id = user.UserId }));
         }
         else
         {
             ModelState.AddModelError("", "Invalid Credentials.");
             return(View());
         }
     }
 }
 public ActionResult RecoveryUserId(UserIdRecovery userIdRecovery)
 {
     if (!ModelState.IsValid)
     {
         return(View());
     }
     else
     {
         using (UserLoginDbContext db = new UserLoginDbContext())
         {
             if (userIdRecovery != null)
             {
                 var user = db.CustomerRegisters.FirstOrDefault(x => x.Answer == userIdRecovery.Answer && x.SecretQuestions == userIdRecovery.SecretQuestions && x.Email == userIdRecovery.Email);
                 ViewBag.msg = "Your User Id is:" + user.UserId;
                 return(View());
             }
             else
             {
                 ModelState.AddModelError("", "Invalid Credentials.");
                 return(View());
             }
         }
     }
 }
Ejemplo n.º 4
0
 public void Save(UserLoginDbContext userContext)
 {
     userContext.SaveChanges();
 }