Ejemplo n.º 1
0
        public bool VerifBdd(User newUser)
        {
            var pseudo = RequestWebApi.GetUserPseudo(newUser.Pseudo);
            var email  = RequestWebApi.GetUserEmail(newUser.Email);

            if (pseudo == null && email == null)
            {
                RequestWebApi.PostUser(newUser);
                return(false);
            }
            else if (pseudo != null)
            {
                EmptyField emptyField = new EmptyField("Username already exist !");
                emptyField.ShowDialog();
                return(true);
            }
            else if (email != null)
            {
                EmptyField emptyField = new EmptyField("Email already exist !");
                emptyField.ShowDialog();
                return(true);
            }
            else
            {
                return(true);
            }
        }
Ejemplo n.º 2
0
        private void Button_Login_Click(object sender, RoutedEventArgs e)
        {
            var test = RequestWebApi.GetUser(TBUsername.Text, PBPsw.Password.ToString());

            if (test != null)
            {
                CurrentUser.currentUser = test;
                LaListe liste = new LaListe();
                liste.Show();
                this.Close();
            }
            else
            {
                EmptyField emptyField = new EmptyField("Username or Password is not valid !");
                emptyField.ShowDialog();
            }
        }
        private void add_Click(object sender, RoutedEventArgs e)

        {
            string messagetest = textBox1.Text.Trim(' ');

            if (messagetest != "")
            {
                Task newTask = new Task {
                    Content = textBox1.Text, IdList = Listprivate.Id, Position = ListItems.Count
                };
                RequestWebApi.PostTask(newTask);
                newTask.Id = RequestWebApi.GetLastTask().Id;
                ListItems.Add(newTask);
                textBox1.Text = "";
            }
            else
            {
                EmptyField error = new EmptyField("Empty field !");
                error.ShowDialog();
                textBox1.Text = "";
            }
        }
Ejemplo n.º 4
0
        private void Button_SignUp_Click(object sender, RoutedEventArgs e)
        {
            string strEMail = textboxEmail.Text;

            bool isMailValid = false;

            try
            {
                var addr = new MailAddress(strEMail);
                //addr.Address == strEMail;
                isMailValid = true;
            }

            catch
            {
                isMailValid = false;
            }

            if (textboxUsername.Text.Trim(' ') != "" &&
                textboxUsername.Text.Length >= 4 &&
                textboxUsername.Text.Length <= 20 &&
                textboxEmail.Text.Trim(' ') != "" &&
                isMailValid &&
                textboxPassword.Password.ToString() == textboxConfirmationPassword.Password.ToString() &&
                textboxPassword.Password.ToString().Trim(' ') != "" &&
                textboxPassword.Password.ToString().Length >= 6)
            {
                User newUser = new User {
                    Pseudo = textboxUsername.Text, Email = textboxEmail.Text, Psw = textboxPassword.Password.ToString()
                };
                if (!VerifBdd(newUser))
                {
                    CurrentUser.currentUser = RequestWebApi.GetLastUser();
                    RequestWebApi.PostList(new ToDoList {
                        IdUser = CurrentUser.currentUser.Id, Title = "Title of my list"
                    });
                    LaListe liste = new LaListe();
                    this.Close();
                    liste.Show();
                }
            }
            else if (textboxUsername.Text.Trim(' ') == "")
            {
                EmptyField emptyField = new EmptyField("Username is empty !");
                emptyField.ShowDialog();
            }
            else if (textboxUsername.Text.Length < 4 || textboxUsername.Text.Length > 20)
            {
                EmptyField emptyField = new EmptyField("Username need to have more than 4 characters and less than 20 characters !");
                emptyField.ShowDialog();
            }
            else if (textboxEmail.Text.Trim(' ') == "")
            {
                EmptyField emptyField = new EmptyField("Email is empty !");
                emptyField.ShowDialog();
            }
            else if (isMailValid == false)
            {
                EmptyField emptyField = new EmptyField("Email is not an email !");
                emptyField.ShowDialog();
            }
            else if (textboxPassword.Password.ToString().Trim(' ') == "")
            {
                EmptyField emptyField = new EmptyField("Password is empty !");
                emptyField.ShowDialog();
            }
            else if (textboxPassword.Password.ToString().Length < 6)
            {
                EmptyField emptyField = new EmptyField("Password need to have more than 6 characters !");
                emptyField.ShowDialog();
            }
            else if (textboxPassword.Password.ToString() != textboxConfirmationPassword.Password.ToString())
            {
                EmptyField emptyField = new EmptyField("Confirmation password need to be the same as password !");
                emptyField.ShowDialog();
            }
        }