예제 #1
0
 public ActionResult Signup(Users model)
 {
     using (context = new CustomFormAuthenticationEntities())
     {
         context.Users.Add(model);
         context.SaveChanges();
     }
     return(RedirectToAction("Login"));
 }
예제 #2
0
 public ActionResult Login(UserModel model)
 {
     using (context = new CustomFormAuthenticationEntities())
     {
         bool IsValidUser = context.Users.Any(user => user.UserName.ToLower() ==
                                              model.UserName.ToLower() && user.UserPassword == model.UserPassword);
         if (IsValidUser)
         {
             FormsAuthentication.SetAuthCookie(model.UserName, false);
             return(RedirectToAction("Index", "Employees"));
         }
         ModelState.AddModelError("", "invalid Username or Password");
         return(View());
     }
 }