private void AcceptCodeConfirmation(object sender, RoutedEventArgs routedEventArgs) { imgErrorCodeConfirmation.Visibility = Visibility.Hidden; tbConfirmationCode.BorderBrush = Brushes.Transparent; bool isValidConfirmationCode; isValidConfirmationCode = ValidationData.ValidateConfirmationCode(tbConfirmationCode.Text); if (isValidConfirmationCode) { bool isEqualConfirmationCode = ValidateEqualsConfirmationCode(); if (isEqualConfirmationCode) { tbConfirmationCode.BorderBrush = Brushes.Green; try { InstanceContext instanceContext = new InstanceContext(this); PlayerManagerClient registry = new PlayerManagerClient(instanceContext); registry.Register(account, accountPlayer); if (responseConfirmation) { OpenMessageBox(Properties.Resources.AccountRegistrationMessage, Properties.Resources.AccountRegistrationMessageTitle, (MessageBoxImage)System.Windows.Forms.MessageBoxIcon.Information); } else { OpenMessageBox(Properties.Resources.NoAccountRegisteredMessage, Properties.Resources.AccountRegistrationMessageTitle, (MessageBoxImage)System.Windows.Forms.MessageBoxIcon.Error); } } catch (EndpointNotFoundException exception) { TelegramBot.SendToTelegram(exception); LogException.Log(this, exception); LogException.ErrorConnectionService(); } MainWindow mainWindow = new MainWindow(); mainWindow.Show(); this.Close(); } else { tbConfirmationCode.BorderBrush = Brushes.Red; OpenMessageBox(Properties.Resources.ErrorEqualConfirmationCodeMessage, Properties.Resources.IncorrectCodeMessageTitle, (MessageBoxImage)System.Windows.Forms.MessageBoxIcon.Warning); } } else { tbConfirmationCode.BorderBrush = Brushes.Red; imgErrorCodeConfirmation.Visibility = Visibility.Visible; OpenMessageBox(Properties.Resources.IncorrectCodeMessage, Properties.Resources.IncorrectCodeMessageTitle, (MessageBoxImage)System.Windows.Forms.MessageBoxIcon.Warning); } }
private bool ValidateCode() { bool isValid = false; if (tbCode.Text != null && ValidationData.ValidateConfirmationCode(tbCode.Text) && code == int.Parse(tbCode.Text)) { tbCode.BorderBrush = Brushes.LightGreen; isValid = true; } else { tbCode.BorderBrush = Brushes.Red; System.Windows.Forms.MessageBox.Show(Properties.Resources.ErrorCodeDetails, Properties.Resources.ErrorCodeConfirmation , MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } return(isValid); }