예제 #1
0
 private void Modify(object sender, RoutedEventArgs routedEventArgs)
 {
     playerEdit = new ServicePlayer();
     emailEdit  = account.Email;
     ValidateDataAccount();
     if (isUpdateData || !emailEdit.Equals(emailAccount))
     {
         if (isValidData)
         {
             try {
                 InstanceContext     instanceContext = new InstanceContext(this);
                 PlayerManagerClient playerManager   = new PlayerManagerClient(instanceContext);
                 bool isValidRepeatEmail             = false;
                 if (isUpdateEmail)
                 {
                     playerManager.SearchRepeatEmailAccount(emailEdit, account.IdAccount);
                     isValidRepeatEmail = responseBoolean;
                 }
                 bool updateEmail = false;
                 if (isUpdateEmail && !isValidRepeatEmail)
                 {
                     playerManager.UpdateEmail(emailEdit, account.IdAccount);
                     updateEmail = responseBoolean;
                 }
                 bool updatePlayer = false;
                 if (isUpdateData)
                 {
                     playerManager.UpdatePlayer(player.NickName, playerEdit);
                     updatePlayer = responseBoolean;
                 }
                 if (updatePlayer || updateEmail)
                 {
                     OpenMessageBox(Properties.Resources.ModifyAccountMessage, Properties.Resources.ModifyAccountMessageTitle, (MessageBoxImage)System.Windows.Forms.MessageBoxIcon.Information);
                 }
                 else
                 {
                     OpenMessageBox(Properties.Resources.NoModifyAccountMessage, Properties.Resources.ModifyAccountMessageTitle, (MessageBoxImage)System.Windows.Forms.MessageBoxIcon.Error);
                 }
                 Lobby lobby = new Lobby();
                 if (isUpdateEmail)
                 {
                     lobby.EmailReceived(emailEdit);
                 }
                 lobby.ColocateBestScores();
                 lobby.ColocatePersonalInformation();
                 lobby.Show();
                 this.Close();
             }
             catch (EndpointNotFoundException exception)
             {
                 TelegramBot.SendToTelegram(exception);
                 LogException.Log(this, exception);
                 LogException.ErrorConnectionService();
             }
         }
         else
         {
             OpenMessageBox(Properties.Resources.IncorrectDataMessage, Properties.Resources.IncorrectCodeMessageTitle, (MessageBoxImage)System.Windows.Forms.MessageBoxIcon.Warning);
             isUpdateData = false;
         }
     }
     else
     {
         OpenMessageBox(Properties.Resources.ModifyLeastDataMessage, Properties.Resources.ModifyLeastDataMessageTile, (MessageBoxImage)System.Windows.Forms.MessageBoxIcon.Warning);
     }
 }