private async Task NextAsync() { try { await ButtonSpinner.SpinAsync(async() => { var user = await ApplicationUserService.GetUserByEmailAsync(UserEmailModel.Email); if (user == null) { ValidationErrorMessage.DisplayError(nameof(UserEmailModel.Email), HESException.GetMessage(HESCode.UserNotFound)); return; } PasswordSignInModel.Email = UserEmailModel.Email; HasSecurityKey = (await Fido2Service.GetCredentialsByUserEmail(UserEmailModel.Email)).Count > 0; AuthenticationStep = AuthenticationStep.EnterPassword; }); } catch (HESException ex) { ValidationErrorMessage.DisplayError(nameof(UserEmailModel.Email), ex.Message); } catch (Exception ex) { Logger.LogError(ex.Message); SetErrorMessage(ex.Message); } }
private async Task EditAccountAsync() { try { await Button.SpinAsync(async() => { var vaults = await SharedAccountService.EditSharedAccountAsync(SharedAccountEditModel); RemoteDeviceConnectionsService.StartUpdateHardwareVaultAccounts(vaults); await ToastService.ShowToastAsync("Shared account updated.", ToastType.Success); await ModalDialogClose(); }); } catch (AlreadyExistException ex) { ValidationErrorMessage.DisplayError(nameof(SharedAccount.Name), ex.Message); } catch (IncorrectUrlException ex) { ValidationErrorMessage.DisplayError(nameof(SharedAccount.Urls), ex.Message); } catch (Exception ex) { Logger.LogError(ex.Message, ex); await ToastService.ShowToastAsync(ex.Message, ToastType.Error); await ModalDialogCancel(); } }
private async Task InviteAdminAsync() { try { await ButtonSpinner.SpinAsync(async() => { var callBakcUrl = await ApplicationUserService.InviteAdministratorAsync(Invitation.Email, NavigationManager.BaseUri); await EmailSenderService.SendUserInvitationAsync(Invitation.Email, callBakcUrl); await ToastService.ShowToastAsync("Administrator invited.", ToastType.Success); await SynchronizationService.UpdateAdministrators(ExceptPageId); await ModalDialogService.CloseAsync(); }); } catch (AlreadyExistException ex) { ValidationErrorMessage.DisplayError(nameof(Invitation.Email), ex.Message); } catch (Exception ex) { Logger.LogError(ex.Message); await ToastService.ShowToastAsync(ex.Message, ToastType.Error); await ModalDialogService.CancelAsync(); } }
private async Task EditTemplateAsync() { try { await Button.SpinAsync(async() => { await TemplateService.EditTemplateAsync(Template); await ToastService.ShowToastAsync("Template updated.", ToastType.Success); await ModalDialogClose(); }); } catch (AlreadyExistException ex) { ValidationErrorMessage.DisplayError(nameof(SharedAccount.Name), ex.Message); } catch (IncorrectUrlException ex) { ValidationErrorMessage.DisplayError(nameof(SharedAccount.Urls), ex.Message); } catch (Exception ex) { Logger.LogError(ex.Message, ex); await ToastService.ShowToastAsync(ex.Message, ToastType.Error); await ModalDialogCancel(); } }
private async Task EditAccountOtpAsync() { try { await ButtonSpinner.SpinAsync(async() => { await EmployeeService.EditPersonalAccountOtpAsync(Account, _accountOtp); RemoteDeviceConnectionsService.StartUpdateHardwareVaultAccounts(await EmployeeService.GetEmployeeVaultIdsAsync(Account.EmployeeId)); await ToastService.ShowToastAsync("Account OTP updated.", ToastType.Success); await SynchronizationService.UpdateEmployeeDetails(ExceptPageId, Account.EmployeeId); await ModalDialogService.CloseAsync(); }); } catch (IncorrectOtpException ex) { ValidationErrorMessage.DisplayError(nameof(AccountOtp.OtpSecret), ex.Message); } catch (Exception ex) { Logger.LogError(ex.Message); await ToastService.ShowToastAsync(ex.Message, ToastType.Error); await ModalDialogService.CloseAsync(); } }
private void HyperlinkButton_AddClick(object sender, RoutedEventArgs e) { Grid gr = (Grid)((HyperlinkButton)e.OriginalSource).Parent; ValidationErrorMessage er = ((GridViewCell)(gr.Parent)).ParentRow.DataContext as ValidationErrorMessage; RetailSystemClient MRSclient = new RetailSystemClient(); MRSclient.Endpoint.Address = new System.ServiceModel.EndpointAddress(Internal.Utilities.GetMetriconRetailSystemWcfClientEndpointUrl()); MRSclient.SaveSelectedItemCompleted += delegate(object o, SaveSelectedItemCompletedEventArgs es) { if (es.Error == null) { if (es.Result > 0) { RefreshErrorMessage(estimaterevisionid); } } else { ExceptionHandler.PopUpErrorMessage(es.Error, "SaveSelectedItemCompleted"); } }; MRSclient.SaveSelectedItemAsync(er.HomeDisplayOptionId, estimaterevisionid, er.PagID, (App.Current as App).CurrentUserId); }
private void HyperlinkButton_AnswerClick(object sender, RoutedEventArgs e) { RadWindow win = new RadWindow(); EstimateDetails pag = new EstimateDetails(); Grid gr = (Grid)((HyperlinkButton)e.OriginalSource).Parent; ValidationErrorMessage er = ((GridViewCell)(gr.Parent)).ParentRow.DataContext as ValidationErrorMessage; mrsClient = new RetailSystemClient(); mrsClient.Endpoint.Address = new System.ServiceModel.EndpointAddress(Internal.Utilities.GetMetriconRetailSystemWcfClientEndpointUrl()); mrsClient.GetPagByIDCompleted += delegate(object o, GetPagByIDCompletedEventArgs es) { if (es.Error == null) { pag = es.Result; AppOptionFromTree acceptDlg = new AppOptionFromTree(pag, "STUDIOM_ANSWER", 0); win.WindowStartupLocation = Telerik.Windows.Controls.WindowStartupLocation.CenterScreen; win.Header = "Add Option Window"; win.Content = acceptDlg; win.Closed += new EventHandler <WindowClosedEventArgs>(win_AddOptionClosed); win.ShowDialog(); } else { ExceptionHandler.PopUpErrorMessage(es.Error, "GetPagByIDCompleted"); } }; mrsClient.GetPagByIDAsync(estimaterevisionid, er.HomeDisplayOptionId); }
private async Task CreateAccountAsync() { try { await ButtonSpinner.SpinAsync(async() => { await EmployeeService.CreatePersonalAccountAsync(PersonalAccount); RemoteDeviceConnectionsService.StartUpdateHardwareVaultAccounts(await EmployeeService.GetEmployeeVaultIdsAsync(EmployeeId)); await ToastService.ShowToastAsync("Account created.", ToastType.Success); await ModalDialogClose(); }); } catch (HESException ex) when(ex.Code == HESCode.AccountExist) { ValidationErrorMessage.DisplayError(nameof(PersonalAccount.Name), ex.Message); } catch (HESException ex) when(ex.Code == HESCode.IncorrectUrl) { ValidationErrorMessage.DisplayError(nameof(PersonalAccount.Urls), ex.Message); } catch (HESException ex) when(ex.Code == HESCode.IncorrectOtp) { ValidationErrorMessage.DisplayError(nameof(PersonalAccount.OtpSecret), ex.Message); } catch (Exception ex) { Logger.LogError(ex.Message); await ToastService.ShowToastAsync(ex.Message, ToastType.Error); await ModalDialogCancel(); } }
private async Task CreateAccountAsync() { try { await ButtonSpinner.SpinAsync(async() => { await EmployeeService.CreatePersonalAccountAsync(PersonalAccount); RemoteDeviceConnectionsService.StartUpdateHardwareVaultAccounts(await EmployeeService.GetEmployeeVaultIdsAsync(EmployeeId)); await Refresh.InvokeAsync(this); await ToastService.ShowToastAsync("Account created.", ToastType.Success); await SynchronizationService.UpdateEmployeeDetails(ExceptPageId, EmployeeId); await ModalDialogService.CloseAsync(); }); } catch (AlreadyExistException ex) { ValidationErrorMessage.DisplayError(nameof(PersonalAccount.Name), ex.Message); } catch (IncorrectUrlException ex) { ValidationErrorMessage.DisplayError(nameof(PersonalAccount.Urls), ex.Message); } catch (IncorrectOtpException ex) { ValidationErrorMessage.DisplayError(nameof(PersonalAccount.OtpSecret), ex.Message); } catch (Exception ex) { Logger.LogError(ex.Message); await ToastService.ShowToastAsync(ex.Message, ToastType.Error); await ModalDialogService.CancelAsync(); } }
public void Before_each_test() { _logger = new Mock <ILogger <UpdateOrganisationHandler> >(); _organisationValidator = new Mock <IOrganisationValidator>(); ; _textSanitiser = new TextSanitiser(); _validationErrorMessage = new ValidationErrorMessage(); _updateOrganisationRepository = new Mock <IUpdateOrganisationRepository>(); _auditLogService = new Mock <IAuditLogService>(); _organisationValidator.Setup(x => x.ValidateOrganisation(It.IsAny <UpdateOrganisationCommand>())) .Returns(_validationErrorMessage); _auditData = new AuditData { }; _auditLogService.Setup(x => x.AuditOrganisation(It.IsAny <UpdateOrganisationCommand>())).Returns(_auditData); _handler = new UpdateOrganisationHandler(_logger.Object, _updateOrganisationRepository.Object, _auditLogService.Object, _organisationValidator.Object, _textSanitiser); _request = new UpdateOrganisationRequest { OrganisationId = Guid.NewGuid(), OrganisationTypeId = 1, ProviderTypeId = 1, LegalName = "legal name", CharityNumber = "1233333", CompanyNumber = "35444444", Username = "******", ApplicationDeterminedDate = DateTime.Today }; }
private async Task EditAsync() { try { await ButtonSpinner.SpinAsync(async() => { await OrgStructureService.EditDepartmentAsync(Department); await ToastService.ShowToastAsync("Department updated.", ToastType.Success); await Refresh.InvokeAsync(this); await SynchronizationService.UpdateOrgSructureCompanies(ExceptPageId); await ModalDialogService.CloseAsync(); }); } catch (AlreadyExistException ex) { ValidationErrorMessage.DisplayError(nameof(Department.Name), ex.Message); } catch (Exception ex) { Logger.LogError(ex.Message); await ToastService.ShowToastAsync(ex.Message, ToastType.Error); await ModalDialogService.CloseAsync(); } }
private async Task CreateAccountAsync() { try { await ButtonSpinner.SpinAsync(async() => { await SharedAccountService.CreateSharedAccountAsync(SharedAccount); await ToastService.ShowToastAsync("Account created.", ToastType.Success); await SynchronizationService.UpdateSharedAccounts(ExceptPageId); await ModalDialogService.CloseAsync(); }); } catch (AlreadyExistException ex) { ValidationErrorMessage.DisplayError(nameof(SharedAccount.Name), ex.Message); } catch (IncorrectUrlException ex) { ValidationErrorMessage.DisplayError(nameof(SharedAccount.Urls), ex.Message); } catch (IncorrectOtpException ex) { ValidationErrorMessage.DisplayError(nameof(SharedAccount.OtpSecret), ex.Message); } catch (Exception ex) { Logger.LogError(ex.Message); await ToastService.ShowToastAsync(ex.Message, ToastType.Error); await ModalDialogService.CloseAsync(); } }
private async Task EditAccoountOtpAsync() { try { await ButtonSpinner.SpinAsync(async() => { var vaults = await SharedAccountService.EditSharedAccountOtpAsync(Account, AccountOtp); RemoteDeviceConnectionsService.StartUpdateHardwareVaultAccounts(vaults); await SynchronizationService.UpdateSharedAccounts(ExceptPageId); await ToastService.ShowToastAsync("Account OTP updated.", ToastType.Success); await ModalDialogService.CloseAsync(); }); } catch (IncorrectOtpException ex) { ValidationErrorMessage.DisplayError(nameof(SharedAccount.OtpSecret), ex.Message); } catch (Exception ex) { Logger.LogError(ex.Message); await ToastService.ShowToastAsync(ex.Message, ToastType.Error); await ModalDialogService.CancelAsync(); } }
public static ResponseEnvelope <T> CreateErrorResponseEnvelope <T>(ValidationErrorMessage message, T content = default(T)) { var response = new ResponseEnvelope <T> { Content = content, Success = false, Error = message, }; return(response); }
public static ValidationErrorMessage Parse(string message) { ValidationErrorMessage msg = new ValidationErrorMessage(); var index = message.IndexOf("Path '"); if (index >= 0) { msg.NodePath = message.Substring(index + 6).Trim(new char[] { '\'', '.' }); msg.Message = message.Substring(0, index).Trim(); } return(msg); }
public void Handler_rejects_request_with_invalid_organisation() { var validationMessage = new ValidationErrorMessage { Message = "error" }; _organisationValidator.Setup(x => x.ValidateOrganisation(It.IsAny <UpdateOrganisationCommand>())) .Returns(validationMessage); _organisationValidator.Setup(x => x.IsValidOrganisationTypeId(It.IsAny <int>())).Returns(false); Func <Task> result = async() => await _handler.Handle(_request, new CancellationToken()); result.Should().Throw <BadRequestException>(); }
// _/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/ // Public Method // _/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/ /// <summary> /// リストの各項目が適切な設定であることを検証する。 /// </summary> /// <remarks> /// 以下の点をチェックする。 /// <pre>「文章の表示」~「ダウンロード処理」でキーが被っていないか</pre> /// <pre>使用していない項目に未使用時の値が設定されているか</pre> /// </remarks> /// <param name="errorMsg"> /// 返戻エラーメッセージ。 /// 設定値が適切である場合、null。 /// </param> /// <returns>設定値が適切である場合、true</returns> public bool Validate(out string errorMsg) { if (!ValidateDuplicateKey(out errorMsg)) { return(false); } if (!ValidateNotUseKeys()) { errorMsg = ValidationErrorMessage.Invalid(); return(false); } errorMsg = null; return(true); }
private void HyperlinkButton_UpgradeClick(object sender, RoutedEventArgs e) { RadWindow win = new RadWindow(); //EstimateDetails pag = new EstimateDetails(); Grid gr = (Grid)((HyperlinkButton)e.OriginalSource).Parent; ValidationErrorMessage er = ((GridViewCell)(gr.Parent)).ParentRow.DataContext as ValidationErrorMessage; string productid = (er.ErrorMessage.Replace("Standard Inclusion - ", "")).Replace(" should be added to estimate.", ""); AddUpgradeFromStandardInclusion acceptDlg = new AddUpgradeFromStandardInclusion(estimaterevisionid, er.HomeDisplayOptionId, productid); win.WindowStartupLocation = Telerik.Windows.Controls.WindowStartupLocation.CenterScreen; win.Header = "Add Upgrade Window"; win.Content = acceptDlg; win.Closed += new EventHandler <WindowClosedEventArgs>(win_AddOptionClosed); win.ShowDialog(); }
private async Task EditRenewLicenseOrderAsync() { try { await ButtonSpinner.SpinAsync(async() => { if (_renewLicenseOrder.EndDate < DateTime.Now) { ValidationErrorMessage.DisplayError(nameof(RenewLicenseOrder.EndDate), $"End Date must not be less than Start Date."); return; } if (!_renewLicenseOrder.HardwareVaults.Where(x => x.Checked).Any()) { ValidationErrorMessage.DisplayError(nameof(RenewLicenseOrder.HardwareVaults), $"Select at least one hardware vault."); return; } var checkedHardwareVaults = _renewLicenseOrder.HardwareVaults.Where(x => x.Checked).ToList(); var maxEndDate = checkedHardwareVaults.Select(x => x.LicenseEndDate).Max(); if (_renewLicenseOrder.EndDate < maxEndDate) { ValidationErrorMessage.DisplayError(nameof(RenewLicenseOrder.HardwareVaults), $"The selected End Date less than max end date for selected hardware vaults."); return; } LicenseOrder.ContactEmail = _renewLicenseOrder.ContactEmail; LicenseOrder.Note = _renewLicenseOrder.Note; LicenseOrder.ProlongExistingLicenses = true; LicenseOrder.StartDate = null; LicenseOrder.EndDate = _renewLicenseOrder.EndDate.Date; await LicenseService.EditOrderAsync(LicenseOrder, checkedHardwareVaults); await SynchronizationService.UpdateLicenses(ExceptPageId); await ToastService.ShowToastAsync("Order created.", ToastType.Success); await ModalDialogService.CloseAsync(); }); } catch (Exception ex) { Logger.LogError(ex.Message); await ToastService.ShowToastAsync(ex.Message, ToastType.Error); await ModalDialogService.CloseAsync(); } }
private void errorGrid_RowLoaded(object sender, Telerik.Windows.Controls.GridView.RowLoadedEventArgs e) { GridViewRow row = e.Row as GridViewRow; if (row != null) { ValidationErrorMessage vms = row.DataContext as ValidationErrorMessage; if (vms.AllowGoAhead) { row.Background = new SolidColorBrush(Color.FromArgb(25, 204, 255, 153));// SolidColorBrush(Colors.Transparent); } else { row.Background = new SolidColorBrush(Color.FromArgb(25, 255, 153, 204)); } } }
/// <summary> /// 使用しているキーが重複していないことを検証する。 /// </summary> /// <returns>キー重複が存在しない場合、true</returns> public bool ValidateDuplicateKey(out string errorMsg) { var cloneList = Items.Where(x => !x.Equals(EventCommandShortCutKey.None)).ToList(); cloneList.Sort((left, right) => String.Compare(left.Code, right.Code, StringComparison.CurrentCultureIgnoreCase)); for (var i = 1; i < cloneList.Count; i++) { if (cloneList[i - 1].Equals(cloneList[i])) { errorMsg = ValidationErrorMessage.Duplicate(cloneList[i]); return(false); } } errorMsg = null; return(true); }
private async Task EditNewLicenseOrderAsync() { try { await Button.SpinAsync(async() => { if (_newLicenseOrder.StartDate < DateTime.Now.Date) { ValidationErrorMessage.DisplayError(nameof(NewLicenseOrder.StartDate), $"Start Date must be at least current date."); return; } if (_newLicenseOrder.EndDate < _newLicenseOrder.StartDate) { ValidationErrorMessage.DisplayError(nameof(NewLicenseOrder.EndDate), $"End Date must not be less than Start Date."); return; } if (!_newLicenseOrder.HardwareVaults.Where(x => x.Checked).Any()) { ValidationErrorMessage.DisplayError(nameof(NewLicenseOrder.HardwareVaults), $"Select at least one hardware vault."); return; } LicenseOrder.ContactEmail = _newLicenseOrder.ContactEmail; LicenseOrder.Note = _newLicenseOrder.Note; LicenseOrder.ProlongExistingLicenses = false; LicenseOrder.StartDate = _newLicenseOrder.StartDate.Date; LicenseOrder.EndDate = _newLicenseOrder.EndDate.Date; var checkedHardwareVaults = _newLicenseOrder.HardwareVaults.Where(x => x.Checked).ToList(); await LicenseService.EditOrderAsync(LicenseOrder, checkedHardwareVaults); await ToastService.ShowToastAsync("Order created.", ToastType.Success); await ModalDialogClose(); }); } catch (Exception ex) { Logger.LogError(ex.Message); await ToastService.ShowToastAsync(ex.Message, ToastType.Error); await ModalDialogCancel(); } }
public bool Validate() { bool valid = true; ErrorMessages.Clear(); IList <string> messages; var obj = Token as JObject; if (!obj.IsValid(Schema, out messages)) { ErrorMessages.AddRange(messages.Select(x => ValidationErrorMessage.Parse(x))); valid = false; } ; OnValidated?.Invoke(this, EventArgs.Empty); return(valid); }
private void ShowValidationError(ValidationErrorMessage m) { foreach (var eve in m.Exception.EntityValidationErrors) { string message = string.Format("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:", eve.Entry.Entity.GetType().Name, eve.Entry.State); Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:", eve.Entry.Entity.GetType().Name, eve.Entry.State); string propertyErrors = ""; foreach (var ve in eve.ValidationErrors) { propertyErrors += string.Format("- Property: \"{0}\", Error: \"{1}\"", ve.PropertyName, ve.ErrorMessage) + Environment.NewLine; } string messageToShow = message + Environment.NewLine + propertyErrors; MessageBox.Show(messageToShow, "Validation Error"); } }
private async Task ChangeEmailAsync() { try { await ButtonChangeEmail.SpinAsync(async() => { await ApplicationUserService.ChangeEmailAsync(ChangeEmailModel); await ToastService.ShowToastAsync("Email confirmation sent.", ToastType.Success); }); } catch (HESException ex) { ValidationErrorMessage.DisplayError(nameof(ChangeEmailModel.NewEmail), ex.Message); } catch (Exception ex) { Logger.LogError(ex.Message); await ToastService.ShowToastAsync(ex.Message, ToastType.Error); } }
private async Task ActivateAsync() { try { await ButtonSpinner.SpinAsync(async() => { var result = await DataProtectionService.ActivateProtectionAsync(Input.Password); if (!result) { ValidationErrorMessage.DisplayError(nameof(InputModel.Password), "Invalid password"); return; } NavigationManager.NavigateTo(""); }); } catch (Exception ex) { Logger.LogError(ex.Message); await ToastService.ShowToastAsync(ex.Message, ToastType.Error); } }
private async Task CreateAsync() { try { await Button.SpinAsync(async() => { await OrgStructureService.CreatePositionAsync(Position); await ToastService.ShowToastAsync("Position created.", ToastType.Success); await ModalDialogClose(); }); } catch (AlreadyExistException ex) { ValidationErrorMessage.DisplayError(nameof(Position.Name), ex.Message); } catch (Exception ex) { Logger.LogError(ex.Message); await ToastService.ShowToastAsync(ex.Message, ToastType.Error); await ModalDialogCancel(); } }
private async Task EditAsync() { try { await ButtonSpinner.SpinAsync(async() => { await EmployeeService.EditEmployeeAsync(Employee); await ToastService.ShowToastAsync("Employee updated.", ToastType.Success); await ModalDialogClose(); }); } catch (AlreadyExistException ex) { ValidationErrorMessage.DisplayError(nameof(Employee.FirstName), ex.Message); } catch (Exception ex) { Logger.LogError(ex.Message); await ToastService.ShowToastAsync(ex.Message, ToastType.Error); await ModalDialogCancel(); } }
private async Task NextAsync() { try { await Button.SpinAsync(async() => { var user = await ApplicationUserService.GetUserByEmailAsync(UserEmailModel.Email); if (user == null) { ValidationErrorMessage.DisplayError(nameof(UserEmailModel.Email), HESException.GetMessage(HESCode.UserNotFound)); return; } await SignInWithSecurityKeyAsync(); }); } catch (Exception ex) { Logger.LogError(ex.Message); SetErrorMessage(ex.Message); } }
private async Task LoginWithPasswordAsync() { try { await ButtonSpinner.SpinAsync(async() => { var response = await IdentityApiClient.LoginWithPasswordAsync(PasswordSignInModel); response.ThrowIfFailed(); if (response.Succeeded) { NavigationManager.NavigateTo(Routes.Dashboard, true); return; } if (response.RequiresTwoFactor) { NavigationManager.NavigateTo($"{Routes.LoginWith2Fa}?returnUrl={ReturnUrl}", true); return; } if (response.IsLockedOut) { NavigationManager.NavigateTo(Routes.Lockout, true); return; } }); } catch (HESException ex) when(ex.Code == HESCode.InvalidLoginAttempt) { ValidationErrorMessage.DisplayError(nameof(PasswordSignInModel.Password), HESException.GetMessage(ex.Code)); } catch (Exception ex) { Logger.LogError(ex.Message); SetErrorMessage(ex.Message); } }