private void Login()
        {
            bool email_validation    = ValidateEmail(email.Text);
            bool password_validation = ValidatePassword(password.Password);

            if (email_validation && password_validation)
            {
                progressbar.Visibility = Visibility.Visible;
                string url = UserCurrent.login(email.Text, password.Password);

                WebClient client = new WebClient();

                client.UploadStringCompleted += client_UploadStringCompleted;
                client.UploadProgressChanged += client_UploadProgressChanged;
                client.UploadStringAsync(new Uri(url), "");

                progressbar.Value = 25;//*/
            }
            else if (!email_validation)
            {
                MessageBox.Show("L'address email n'est pas valide");
            }
            else if (!password_validation)
            {
                MessageBox.Show("Le mot de passe doit contenir au moins 8 caractère");
            }
        }
 void client_UploadStringCompleted(object sender, UploadStringCompletedEventArgs e)
 {
     if (e.Error == null)
     {
         progressbar.Value      = 100;
         progressbar.Visibility = Visibility.Collapsed;
         ResponseApi api = ResponseApi.GetResponseApiFrom(e.Result);
         if (api.isSuccess())
         {
             UserCurrent.Create(email.Text, password.Password);
             NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.Relative));
             NavigationService.RemoveBackEntry();
         }
         else
         {
             MessageBox.Show("The user Exist or Wrong Password");
         }
     }
     else
     {
         progressbar.Value = 25;
         MessageBoxResult msg_box = MessageBox.Show(e.Error.Message + " Server Ne repond Pas", "Do you want to Retry", MessageBoxButton.OKCancel);
         if (msg_box == MessageBoxResult.OK)
         {
             Login();
         }
     }
 }
        private void updateBtn_Click(object sender, RoutedEventArgs e)
        {
            string url = UserCurrent.findPos(NameFriend.Text);

            WebClient client = new WebClient();

            client.UploadStringCompleted += client_UploadStringCompleted;

            client.UploadStringAsync(new Uri(url), "");
        }
示例#4
0
        private void search()
        {
            string url = UserCurrent.findPos(Searched);

            WebClient client = new WebClient();

            client.UploadStringCompleted += search_UploadStringCompleted;
            client.UploadProgressChanged += search_UploadProgressChanged;
            client.UploadStringAsync(new Uri(url), "");

            progressbar.Visibility = Visibility.Visible;
            progressbar.Value      = 25;
        }
 public static void Create(string email, string password)
 {
     singleton = new UserCurrent(email, password);
 }