private void SendCodeConfirmation(object sender, RoutedEventArgs routedEventArgs)
        {
            int codeConfirmation = ValidationData.GenerateConfirmationCode();

            account.ConfirmationCode = codeConfirmation;
            SendConfirmationCodePlayer();
        }
 private void SendRecoveryCode(object sender, RoutedEventArgs eventSendCode)
 {
     if (ValidateEmail() && SearchEmail())
     {
         try
         {
             InstanceContext     instanceContext = new InstanceContext(this);
             PlayerManagerClient sendCode        = new PlayerManagerClient(instanceContext);
             int code = ValidationData.GenerateConfirmationCode();
             sendCode.SendEmail(tbEmail.Text, code);
             RecoverAccount recover = new RecoverAccount();
             recover.EmailReceived(tbEmail.Text);
             recover.CodeReceived(code);
             recover.Show();
             this.Close();
         }
         catch (EndpointNotFoundException exception)
         {
             TelegramBot.SendToTelegram(exception);
             LogException.Log(this, exception);
             LogException.ErrorConnectionService();
             CloseWindow();
         }
     }
 }
Example #3
0
        private void RegisterPlayer(object sender, RoutedEventArgs routedEventArgs)
        {
            bool isValidData = ValidateDataPlaye();

            if (isValidData)
            {
                string name             = tbName.Text;
                string lastName         = tbLastName.Text;
                string nickname         = tbNickname.Text;
                string email            = tbEmail.Text;
                string password         = Security.Encrypt(pbPassword.Password);
                int    codeConfirmation = ValidationData.GenerateConfirmationCode();

                ServiceAccount account = new ServiceAccount();
                account.PasswordAccount  = password;
                account.Email            = email;
                account.ConfirmationCode = codeConfirmation;

                ServicePlayer accountPlayer = new ServicePlayer();
                accountPlayer.NickName      = nickname;
                accountPlayer.NamePlayer    = ValidationData.DeleteSpaceWord(name);
                accountPlayer.LastName      = ValidationData.DeleteSpaceWord(lastName);
                accountPlayer.StatusPlayer  = "Active";
                accountPlayer.ScoreObtained = 0;

                try {
                    InstanceContext     instanceContext = new InstanceContext(this);
                    PlayerManagerClient validatePlayer  = new PlayerManagerClient(instanceContext);
                    validatePlayer.SearchNicknamePlayer(nickname);
                    bool isValidRepeatNickname = responseBoolean;
                    validatePlayer.SearchEmailPlayer(email);
                    bool isValidRepeatEmail = responseBoolean;

                    if (isValidRepeatEmail && isValidRepeatNickname)
                    {
                        OpenMessageBox(Properties.Resources.RegisteredEmailNicknameMessage, Properties.Resources.RepeatedDataMessageTitle, (MessageBoxImage)System.Windows.Forms.MessageBoxIcon.Warning);
                    }
                    else
                    {
                        if (isValidRepeatEmail)
                        {
                            OpenMessageBox(Properties.Resources.RegisteredEmailMessage, Properties.Resources.RepeatedDataMessageTitle, (MessageBoxImage)System.Windows.Forms.MessageBoxIcon.Warning);
                        }
                        else
                        {
                            if (isValidRepeatNickname)
                            {
                                OpenMessageBox(Properties.Resources.RegisteredNicknameMessage, Properties.Resources.RepeatedDataMessageTitle, (MessageBoxImage)System.Windows.Forms.MessageBoxIcon.Warning);
                            }
                            else
                            {
                                EmailConfirmation emailConfirmation = new EmailConfirmation();
                                emailConfirmation.AccountReceived(account);
                                emailConfirmation.PlayerReceived(accountPlayer);
                                emailConfirmation.SendConfirmationCodePlayer();
                                emailConfirmation.Show();
                                this.Close();
                            }
                        }
                    }
                }
                catch (EndpointNotFoundException exception)
                {
                    TelegramBot.SendToTelegram(exception);
                    LogException.Log(this, exception);
                    LogException.ErrorConnectionService();
                }
            }
            else
            {
                OpenMessageBox(Properties.Resources.IncorrectDataMessage, Properties.Resources.IncorrectDataMessageTitle, (MessageBoxImage)System.Windows.Forms.MessageBoxIcon.Warning);
            }
        }