コード例 #1
0
 public ActionResult Signup(User model)
 {
     using (var context = new office_dbEntities())
     {
         context.Users.Add(model);
         context.SaveChanges();
     }
     return(RedirectToAction("Login"));
 }
コード例 #2
0
 public ActionResult Login(Context.Membership model)
 {
     using (var context = new office_dbEntities())
     {
         bool isValid = context.Users.Any(x => x.Username == model.UserName && x.Password == model.Password);
         if (isValid == true)
         {
             FormsAuthentication.SetAuthCookie(model.UserName, false);
             return(RedirectToAction("Index", "Employees"));
         }
         else
         {
             ModelState.AddModelError("", "Invalid User Name");
             return(View());
         }
     }
     return(View());
 }