コード例 #1
0
        private async void TryAutoLogin()
        {
            var navService  = new Services.NavigationService();
            var userService = new Services.UserService();
            var autoLoginOk = await userService.TryAutoLogin();

            if (autoLoginOk)
            {
                await Task.Delay(1000);

                navService.GoToHome();
                return;
            }

            await Task.Delay(1000);

            navService.GoToLogin();
        }
コード例 #2
0
        public SettingsPageViewModel()
        {
            LogoutCommand = new Command(execute: async() =>
            {
                var confirm = await Application.Current.MainPage.DisplayAlert(Resx.AppResources.Logout, Resx.AppResources.LogoutConfirm, Resx.AppResources.Yes, Resx.AppResources.Cancel);
                if (confirm)
                {
                    var userService       = new Services.UserService();
                    var navigationService = new Services.NavigationService();
                    userService.DoLogout();
                    navigationService.GoToLogin();
                }
            });

            ChangePasswordCommand = new Command(execute: () =>
            {
                var navigationService = new Services.NavigationService();
                navigationService.GoToChangePasswordPage();
            });

            LoadUserData();
        }
コード例 #3
0
        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();
                }
            }
        }