Ejemplo n.º 1
0
        private async void SignupValidation_ButtonClicked(object sender, EventArgs e)
        {
            if (string.IsNullOrWhiteSpace(loginEntry.Text) || string.IsNullOrWhiteSpace(emailEntry.Text) ||
                string.IsNullOrWhiteSpace(passwordEntry.Text) || string.IsNullOrWhiteSpace(confirmpasswordEntry.Text) ||
                string.IsNullOrWhiteSpace(phoneEntry.Text))
            {
                await DisplayAlert("Sing Up", "Please fill in all fields ", "OK");
            }
            else
            {
                User                    user      = CreateUser();
                IvalidateUser           validator = new ValidateUser();
                List <ValidationResult> Errors    = await validator.ValidateNewUser(user, confirmpasswordEntry.Text);

                if (Errors.Count == 0)
                {
                    await DisplayAlert("Sing Up", "Registration successful", "OK");

                    await Navigation.PushAsync(new LoginPage());
                }
                else
                {
                    ShowErrors(Errors);
                }
            }
        }
Ejemplo n.º 2
0
 public IActionResult Post([FromBody] User user)
 {
     user = ValidateUser.ValidateNewUser(user);
     if (user != null)
     {
         _db.Users.InsertOne(user);
         return(Ok());
     }
     else
     {
         return(BadRequest("Registered email or document"));
     }
 }