public async Task OnSaveAsync() { #region 進行 Form Validation 檢查驗證作業 if (LocalEditContext.Validate() == false) { return; } #endregion #region 其他資料完整性驗證 #endregion #region 進行密碼變更 await AccountPolicyService.UpdateAsync(AccountPolicyModel); await thisView.NeedRefreshAsync(); await Task.Delay(200); MessageBox.Show("400px", "200px", "通知", "紀錄已經儲存成功", MessageBox.HiddenAsync); #endregion }
public async Task OnRecordEditConfirm() { #region 進行 Form Validation 檢查驗證作業 if (LocalEditContext.Validate() == false) { return; } #endregion #region 檢查資料完整性 if (isNewRecordMode == true) { if (string.IsNullOrEmpty(CurrentRecord.PasswordPlaintext)) { MessageBox.Show("400px", "200px", "警告", ErrorMessageMappingHelper.Instance.GetErrorMessage(ErrorMessageEnum.密碼不能為空白), MessageBox.HiddenAsync); thisView.NeedRefresh(); return; } var checkedResult = await CurrentService .BeforeAddCheckAsync(CurrentRecord); if (checkedResult.Success == false) { MessageBox.Show("400px", "200px", "警告", VerifyRecordResultHelper.GetMessageString(checkedResult), MessageBox.HiddenAsync); thisView.NeedRefresh(); return; } CurrentRecord.Salt = Guid.NewGuid().ToString(); CurrentRecord.Password = PasswordHelper.GetPasswordSHA(CurrentRecord.Salt, CurrentRecord.PasswordPlaintext); } else { var checkedResult = await CurrentService .BeforeUpdateCheckAsync(CurrentRecord); if (checkedResult.Success == false) { MessageBox.Show("400px", "200px", "警告", VerifyRecordResultHelper.GetMessageString(checkedResult), MessageBox.HiddenAsync); thisView.NeedRefresh(); return; } if (string.IsNullOrEmpty(CurrentRecord.PasswordPlaintext) == false) { CurrentRecord.Password = PasswordHelper.GetPasswordSHA(CurrentRecord.Salt, CurrentRecord.PasswordPlaintext); } } #endregion if (IsShowEditRecord == true) { if (isNewRecordMode == true) { var verifyRecordResult = await CurrentService.AddAsync(CurrentRecord); await TranscationResultHelper.CheckDatabaseResult(MessageBox, verifyRecordResult); dataGrid.RefreshGrid(); } else { var verifyRecordResult = await CurrentService.UpdateAsync(CurrentRecord); await TranscationResultHelper.CheckDatabaseResult(MessageBox, verifyRecordResult); dataGrid.RefreshGrid(); } IsShowEditRecord = false; } }
public async Task OnRecordEditConfirm() { #region 進行 Form Validation 檢查驗證作業 if (LocalEditContext.Validate() == false) { return; } #endregion #region 檢查資料完整性 if (isNewRecordMode == true) { var checkedResult = await CurrentService .BeforeAddCheckAsync(CurrentRecord); if (checkedResult.Success == false) { MessageBox.Show("400px", "200px", "警告", VerifyRecordResultHelper.GetMessageString(checkedResult), MessageBox.HiddenAsync); await thisView.NeedRefreshAsync(); return; } } else { var checkedResult = await CurrentService .BeforeUpdateCheckAsync(CurrentRecord); if (checkedResult.Success == false) { MessageBox.Show("400px", "200px", "警告", VerifyRecordResultHelper.GetMessageString(checkedResult), MessageBox.HiddenAsync); await thisView.NeedRefreshAsync(); return; } } #endregion if (IsShowEditRecord == true) { if (isNewRecordMode == true) { var verifyRecordResult = await CurrentService.AddAsync(CurrentRecord); await TranscationResultHelper.CheckDatabaseResult(MessageBox, verifyRecordResult); dataGrid.RefreshGrid(); } else { var verifyRecordResult = await CurrentService.UpdateAsync(CurrentRecord); await TranscationResultHelper.CheckDatabaseResult(MessageBox, verifyRecordResult); dataGrid.RefreshGrid(); } IsShowEditRecord = false; } }
public async Task OnSaveAsync() { Relogin = false; var PasswordStrength = PasswordCheck.GetPasswordStrength(ChangePasswordModel.NewPassword); PasswordStrengthName = PasswordStrength.ToString(); MyUserAdapterModel myUserAdapterModel = new MyUserAdapterModel(); #region 進行 Form Validation 檢查驗證作業 if (LocalEditContext.Validate() == false) { return; } #endregion #region 其他資料完整性驗證 if (ChangePasswordModel.NewPasswordAgain != ChangePasswordModel.NewPassword) { MessageBox.Show("400px", "200px", ErrorMessageMappingHelper.Instance.GetErrorMessage(ErrorMessageEnum.警告), ErrorMessageMappingHelper.Instance.GetErrorMessage(ErrorMessageEnum.新密碼2次輸入須相同), CloseMessageBox); return; } else { myUserAdapterModel = await ChangePasswordService.GetCurrentUser(); if (myUserAdapterModel == null) { MessageBox.Show("400px", "200px", ErrorMessageMappingHelper.Instance.GetErrorMessage(ErrorMessageEnum.警告), ErrorMessageMappingHelper.Instance.GetErrorMessage(ErrorMessageEnum.使用者不存在), CloseMessageBox); return; } } #endregion string msg = await ChangePasswordService .CheckWetherCanChangePassword(myUserAdapterModel, ChangePasswordModel.NewPassword); if (string.IsNullOrEmpty(msg) == false) { MessageBox.Show("400px", "200px", ErrorMessageMappingHelper.Instance.GetErrorMessage(ErrorMessageEnum.警告), msg, CloseMessageBox); return; } #region 進行密碼變更 await ChangePasswordService.ChangePassword(myUserAdapterModel, ChangePasswordModel.NewPassword, HttpContextAccessor.GetConnectionIP()); Relogin = true; MessageBox.Show("400px", "200px", ErrorMessageMappingHelper.Instance.GetErrorMessage(ErrorMessageEnum.警告), ErrorMessageMappingHelper.Instance.GetErrorMessage(ErrorMessageEnum.密碼已經變更成功), CloseMessageBox); #endregion }