コード例 #1
0
 public ActionResult SignUp(Person model)
 {
     using (var context = new TwitterCloneDbContext())
     {
         context.Person.Add(model);
         context.SaveChanges();
     }
     return(RedirectToAction("login"));
 }
コード例 #2
0
        public ActionResult Login(Person person)
        {
            using (var context = new TwitterCloneDbContext())
            {
                bool isValid = context.Person.Any(x => x.UserId == person.UserId && x.Password == person.Password);
                if (isValid)
                {
                    FormsAuthentication.SetAuthCookie(person.UserId, false);
                    return(RedirectToAction("Index", "Home"));
                }

                ModelState.AddModelError("", "Invalid Used details");
            }
            return(View());
        }