コード例 #1
0
 public ActionResult SignUp(User model)
 {
     using (var context = new officeEntities())
     {
         context.User.Add(model);
         context.SaveChanges();
     }
     return(RedirectToAction("Login"));
 }
コード例 #2
0
 public ActionResult Login(Models.Membership model)
 {
     using (var context = new officeEntities())
     {
         bool isValid = context.User.Any(x => x.UserName == model.UserName && x.Passsword == model.Password);
         if (isValid)
         {
             FormsAuthentication.SetAuthCookie(model.UserName, false);
             return(RedirectToAction("Index", "Employees"));
         }
         ModelState.AddModelError("", "Invalid UserName and password");
         return(View());
     }
 }