private void RegisterButton_Click(object sender, RoutedEventArgs e) { // Get the Form inputs values: String username, email, password; username = RegisterUsername.Text; email = RegisterEmail.Text; password = RegisterPassword.Password.ToString(); // Check if any of the value was missed bool isFormValid = ValidateRegisterForm(username, email, password); // If Form is valid add new user to database: if (isFormValid) { // Build a new user and add it to the database: UserBuilder builder = new UserBuilder(); builder.SetEmail(email).SetUsername(username).SetPassword(password); User newUser = builder.Build(); userRepo.Add(newUser); userRepo.Save(); MessageBox.Show($"{username} created!"); // Redirect user to the Task Mamanger: TaskCreation tc = new TaskCreation(newUser); tc.Show(); this.Close(); } }
private void LoginButton_Click(object sender, RoutedEventArgs e) { // Get the Form inputs values: String email, password; email = LoginEmail.Text; password = LoginPassword.Password.ToString(); User user = CheckIfUserExists(email); // CHECK IF USER PASSED CORRECT VALUES: if (user == null) { MessageBox.Show("Incorrect username or password!"); } else if (user.Password == password) { MessageBox.Show("Logging in...Click OK"); TaskCreation taskCreation = new TaskCreation(user); taskCreation.Show(); this.Close(); } else { MessageBox.Show("Incorrect username or password!"); } }