Ejemplo n.º 1
0
        public ActionResult ChangePassword(AccountModels.ChangePassword ChangePassword)
        {
            string data = "";

            if (ModelState.IsValid)
            {
                UserProfile User = UserProfileService.GetByID(Convert.ToInt32(Session[KeyList.SessionKeys.UserID].ToString()));

                if (UserProfileService.Decryptdata(User.Password) == ChangePassword.CHOldPassword)
                {
                    if (UserProfileService.Decryptdata(User.Password) != ChangePassword.CHNewPassword)
                    {
                        User.Password = UserProfileService.PasswordEncrypt(ChangePassword.CHNewPassword);
                        UserProfileService.UpdateUser(User);
                        Logs GenerateLog = new Logs();
                        GenerateLog.CreateLog(User.UserId, KeyList.LogMessages.ChangePassword);
                        data = ViewBag.ChangePasswordError = "Password Changed Sucessfully";
                        //data = ;
                        return(Redirect(Url.Action("MyProfile", "Register_Login")));
                    }
                    ViewBag.ChangePasswordError = "Old Password is same with New password";
                    return(View("MyProfile"));
                }
                ViewBag.ChangePasswordError = "Wrong Password";
                return(View("MyProfile"));
            }

            return(View("MyProfile"));
        }