コード例 #1
0
 public ActionResult Create(NewAccount account)
 {
     if (ModelState.IsValid)
     {
         AccountDAO accountDAO = new AccountDAO();
         bool       check      = accountDAO.AddUser(new Account
         {
             Email    = account.Email,
             Password = account.Password,
             Name     = account.Name,
             Phone    = account.Phone,
             DoB      = account.DoB,
             Status   = "active",
             Role     = "client"
         });
         if (check)
         {
             return(RedirectToAction("Login", "Login"));
         }
         else
         {
             ModelState.AddModelError("", "Email is existed !");
             return(View("Create"));
         }
     }
     return(View("Create"));
 }
コード例 #2
0
 public ActionResult Create(Account newAccount)
 {
     if (ModelState.IsValid)
     {
         var  AccountDao = new AccountDAO();
         bool check      = AccountDao.AddUser(newAccount);
         if (check)
         {
             return(RedirectToAction("Index", "Account"));
         }
         else
         {
             ModelState.AddModelError("", "Add user not success !");
         }
     }
     return(View("Index"));
 }