コード例 #1
0
        public ActionResult Create(Account account)
        {
            if (ModelState.IsValid)
            {
                db.Accounts.Add(account);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            return View(account);
        }
コード例 #2
0
        public ActionResult ForgotPass(Account acc)
        {
            var list = db.Accounts.Where(a => a.UserName == acc.UserName).ToList();

            if(list.Count > 0)
            {
                if (list[0].Mail == acc.Mail)
                {
                }

            }

            ViewBag.Message = "Password sent your email!";
            return View();
        }
コード例 #3
0
        public ActionResult Login(Account account)
        {
            if (ModelState.IsValid)
            {
                List<Account> l = db.Accounts.Where(a => a.UserName == account.UserName).ToList();

                if (l.Count > 0)
                {
                    if (l[0].Password == account.Password)
                    {
                        FormsAuthentication.SetAuthCookie(account.UserName, true);
                        return RedirectToAction("Index", "Home");

                    }
                }
            }

            ModelState.AddModelError("", "Invalid username or password!");
            return View();
        }
コード例 #4
0
 public ActionResult Edit(Account account)
 {
     if (ModelState.IsValid)
     {
         db.Entry(account).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     return View(account);
 }