Esempio n. 1
0
 private async void ConfirmRegBtnClick(object sender, MouseButtonEventArgs e)
 {
     if (IsDataValid())
     {
         WrongPasswordInput.Visibility  = Visibility.Hidden;
         EditProfileErrorBox.Visibility = Visibility.Hidden;
         if (RegisterLogin.Text != String.Empty)
         {
             CurrentUser.NickName = RegisterLogin.Text;
         }
         if (MailBox.Text != String.Empty)
         {
             CurrentUser.Email = MailBox.Text;
         }
         if (RegisterPassbox1.Password.Length != 0)
         {
             CurrentUser.Password = RegisterPassbox1.Password;
         }
         if (CurrentUser.ImagePath != null)
         {
             CurrentUser.Image = File.ReadAllBytes(CurrentUser.ImagePath);
         }
         try
         {
             Service1Client client = new Service1Client();
             if (await client.EditProfileAsync(CurrentUser))
             {
                 OnProfileEdited?.Invoke(CurrentUser);
                 CancelRegBtnClick(this, null);
             }
         }
         catch (FaultException <EditFailed> exception)
         {
             WrongPasswordInput.Visibility  = Visibility.Hidden;
             EditProfileErrorBox.Visibility = Visibility.Visible;
             EditProfileErrorMessage.Text   = exception.Detail.Message;
             return;
         }
         catch
         {
             EditProfileErrorBox.Visibility = Visibility.Visible;
             EditProfileErrorMessage.Text   =
                 "Network issues. Please check your\n;internet connection and try again.";
             return;
         }
         WrongPasswordInput.Visibility  = Visibility.Hidden;
         EditProfileErrorBox.Visibility = Visibility.Hidden;
     }
 }
 public void ProfileEdited(ProfileData editedProfile)
 {
     OnProfileEdited?.Invoke(editedProfile);
 }