public void Save() { try { if (string.IsNullOrEmpty(OldPassword)) { Helpers.ShowErrorMessage("Masukkan Password Sebelumnya"); return; } if (string.IsNullOrEmpty(NewPassword)) { Helpers.ShowErrorMessage("Masukkan Password Baru"); return; } if (string.IsNullOrEmpty(NewPassword)) { Helpers.ShowErrorMessage("Confirm Password Baru"); return; } if (OldPassword != Authorization.User.Password) { Helpers.ShowErrorMessage("Password Sebelumnya Salah"); return; } if (NewPassword != ConfirmPassword) { Helpers.ShowErrorMessage("Password Baru dan Confirm Password Tidak sama "); return; } UserManagement userManagement = new UserManagement(); if (userManagement.ChangePassword(Authorization.User, NewPassword)) { Helpers.ShowMessage("Password Anda Berhasil Diubah"); WindowClose(); } } catch (Exception ex) { Helpers.ShowErrorMessage(ex.Message); } }
private void OnChangePassword(Grid grid) { if (grid == null) { return; } IDictionary <string, string> passwords = GetPasswords(grid); string old = passwords["Old"]; string newPassword = passwords["New"]; bool changed = UserManagement.ChangePassword(Repository, old, newPassword); if (changed) { MessageBoxHelper.ShowMessage(Resources.TXT_PASSWORD_HAS_BEEN_CHANGED); } else { MessageBoxHelper.ShowError(Resources.ERR_COULD_NOT_CHANGE_PASSWORD); } ClearPasswords(grid); }