public RegisterPageViewModel() { RegisterData = new RegisterModel(); SaveRegisterDataCommand = new Command(async() => { if (!UserValidations.IsnotEmpty(RegisterData.UserName)) { Result = "El nombre de usuario es requerido"; } else if (!UserValidations.IsnotEmpty(RegisterData.Email)) { Result = "El Email de usuario es requerido"; } else if (!UserValidations.IsnotEmpty(RegisterData.Password) || !UserValidations.IsnotEmpty(RegisterData.ConfirmPassword)) { Result = "Las contraseña es requerida "; } else if (!UserValidations.IsEqual(RegisterData.Password, RegisterData.ConfirmPassword)) { Result = "Las contraseñas no coinciden"; } else { await Application.Current.MainPage.Navigation.PushModalAsync(new HomePage()); } }); }
public LoginPageViewModel() { UserData = new LoginModel(); SaveLoginDataCommand = new Command(async() => { if (!UserValidations.IsnotEmpty(UserData.UserName)) { Result = "El nombre de usuario es requerido"; } else if (!UserValidations.IsnotEmpty(UserData.Password)) { Result = "La contraseña es requerida."; } else { await Application.Current.MainPage.Navigation.PushModalAsync(new NavigationPage(new ContactListPage() { BackgroundColor = Color.CadetBlue })); } }); ToRegistePage = new Command(async() => { await Application.Current.MainPage.Navigation.PushAsync(new RegisterPage()); }); }
async Task RegisterValidations(RegisterModel register) { if (!UserValidations.IsnotEmpty(register.UserName)) { Result = ErrorCodes.UserNameRequired; } else if (!UserValidations.IsnotEmpty(register.Password)) { Result = ErrorCodes.PasswordRequired; } else if (!UserValidations.IsEqual(register.Password, ConfirmPassword)) { Result = ErrorCodes.PassNoMatch; } else if (!UserValidations.IsnotEmpty(register.Email)) { Result = ErrorCodes.UserEmailRequired; } else if (!UserValidations.NumberIsNotEmpty(register.Number)) { Result = ErrorCodes.TelNumberRequired; } else { await ToHomePage(); } }
async Task LoginValidations(LoginModel login) { if (!UserValidations.IsnotEmpty(login.UserName)) { Result = ErrorCodes.UserNameRequired; } else if (!UserValidations.IsnotEmpty(login.Password)) { Result = ErrorCodes.PasswordRequired; } else { await ToHomePage(); } }