private async void ClickRegistrar() { if (BlockRegister) { return; } BlockRegister = true; Application.Current.MainPage.Unfocus(); var userService = new Services.UserService(); var toastService = new Services.ToastService(); var result = await userService.RegisterUser(Username.Trim(), Email.Trim(), Password.Trim()); if (result != UsuarioResultEnum.Ok) { BlockRegister = false; toastService.SendToast(result.GetText()); } else { toastService.SendToast(Resx.AppResources.RegisterOkMsg); await Task.Delay(2000); var navigationService = new Services.NavigationService(); navigationService.GoBack(); } }
private async void DoLogin() { if (BlockLogin) { return; } BlockLogin = true; Application.Current.MainPage.Unfocus(); var userService = new Services.UserService(); var toastService = new Services.ToastService(); var result = await userService.TryLogin(Username.Trim(), Password.Trim()); if (result.Item1 != UsuarioResultEnum.Ok) { toastService.SendToast(result.Item1.GetText()); } else { var resultStore = await userService.SaveUserLoginDataAsync(Username.Trim(), Password.Trim()); if (!resultStore) { toastService.SendToast(Resx.AppResources.NoAutologinSupport); } userService.SaveActiveUserId(result.Item2.Id); var navigationService = new Services.NavigationService(); navigationService.GoToHome(); } BlockLogin = false; }
public async void ChangePassword() { var confirm = await Application.Current.MainPage.DisplayAlert(Resx.AppResources.ChangePasswordTitle, Resx.AppResources.ChangePasswordWarning, Resx.AppResources.Yes, Resx.AppResources.Cancel); if (confirm) { var userService = new Services.UserService(); var result = await userService.ChangePassword(OldPassword.Trim(), NewPassword.Trim()); if (result != UsuarioResultEnum.Ok) { var toastService = new Services.ToastService(); toastService.SendToast(result.GetText()); } else { var navigationService = new Services.NavigationService(); userService.DoLogout(); navigationService.GoToLogin(); } } }