コード例 #1
0
ファイル: AccountController.cs プロジェクト: lequydon/.NETMVC
 public ActionResult ChangePwd(Account account, String oldPassword, String reNewPassword)
 {
     if (Request.HttpMethod == "GET")
     {
         return(View());
     }
     else
     {
         try
         {
             WebUserData userData = User.GetUserData();
             account.Email = userData.UserID;
             Account oldAccount = new Account();
             oldAccount.Email    = account.Email;
             oldAccount.Password = oldPassword;
             if (UserAccountBLL.Account_Get(oldAccount, UserAccountTypes.Employee))
             {
                 if (account.Password == reNewPassword)
                 {
                     UserAccountBLL.Account_Update(account, UserAccountTypes.Employee);
                     return(RedirectToAction("Index", "DashBoard"));
                 }
                 ModelState.AddModelError("reNewPass", "Password incorrect,please try again");
                 return(View());
             }
             else
             {
                 ModelState.AddModelError("", "Wrong password");
                 return(View());
             }
         }
         catch (Exception ex)
         {
             ModelState.AddModelError("", ex.Message + ": " + ex.StackTrace);
             return(View());
         }
     }
 }