Exemplo n.º 1
0
 public ActionResult Autherize(LoginPage.Models.User userModel)
 {
     using (FirstDatabaseEntities db = new FirstDatabaseEntities())
     {
         var userDetails = db.Users.Where(x => x.UserName == userModel.UserName && x.password == userModel.password).FirstOrDefault();
         if (userDetails == null)
         {
             userModel.LoginErrorMessage = "Worng username or password";
             return(View("Index", userModel));
         }
         else
         {
             Session["UserID"]   = userDetails.UserID;
             Session["UserName"] = userDetails.UserName;
             return(RedirectToAction("Index", "Home"));
         }
     }
 }
Exemplo n.º 2
0
 public ActionResult Authorize(LoginPage.Models.User userModel)
 {
     using (LoginDataBaseEntities db = new LoginDataBaseEntities())
     {
         var userDetails = db.Users.Where(x => x.UserName == userModel.UserName && x.Password == userModel.Password).FirstOrDefault();
         if (userDetails == null)
         {
             userModel.LoginErrorMessage = "Wrong username or password.";
             return(View("Index", userModel));
         }
         else
         {
             Session["userID"]   = userDetails.UserID;
             Session["userName"] = userDetails.UserName; //for saving user login details
             return(RedirectToAction("Index", "Home"));
         }
     }
 }