Ejemplo n.º 1
0
        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);
            }
        }