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 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(); } }