Example #1
0
        public async virtual void ForceLogout()
        {
            try
            {
                var isClose = _shiftService.CloseListShift(App.OpenShiftId, App.UserId);
                if (isClose)
                {
                    App.CheckShift = false;
                    var logoutData = await _authService.Logout(App.Email);

                    if (logoutData == null)
                    {
                        SecureStorage.RemoveAll();
                        Application.Current.MainPage = new NavigationPage(new Login());
                    }
                    else if (logoutData.IsError != System.Net.HttpStatusCode.OK)
                    {
                        SecureStorage.RemoveAll();
                        Application.Current.MainPage = new NavigationPage(new Login());
                    }
                    else
                    {
                        SecureStorage.RemoveAll();
                        await PopupNavigation.Instance.PopAllAsync();

                        ErrorViewModel errorViewModel = new ErrorViewModel("กรุณาเข้าสู่ระบบใหม่อีกครั้ง", 1);
                        await PopupNavigation.Instance.PushAsync(new Error(errorViewModel));

                        Application.Current.MainPage = new NavigationPage(new Login());
                    }
                }
                else
                {
                    SecureStorage.RemoveAll();
                    Application.Current.MainPage = new NavigationPage(new Login());
                }
            }
            catch (Exception e)
            {
                SecureStorage.RemoveAll();
                Application.Current.MainPage = new NavigationPage(new Login());
            }
        }
Example #2
0
        private async void CloseShiftList(object obj)
        {
            var isClose = _shiftService.CloseListShift(App.OpenShiftId, App.UserId);

            if (isClose)
            {
                App.CheckShift       = false;
                App.Current.MainPage = new NavigationPage(new Views.EnterPin());
            }
            else
            {
                ErrorViewModel errorViewModel = new ErrorViewModel("Error to Close", 1);
                await PopupNavigation.Instance.PushAsync(new Error(errorViewModel));
            }
        }