Exemple #1
0
        public async Task CheckAndNavigateToMainShell(object sender, ItemClickEventArgs e)
        {
            if (IsLoading)
            {
                return;
            }
            var user = e.ClickedItem as AccountUser;

            if (user == null)
            {
                return;
            }
            var loginResult = false;

            loginResult = await LoginTest(user);

            if (loginResult)
            {
                if (Shell.Instance.ViewModel.CurrentUser != null)
                {
                    await AccountAuthHelpers.UpdateUserIsDefault(Shell.Instance.ViewModel.CurrentUser);
                }
                Shell.Instance.ViewModel.CurrentUser = user;
                Shell.Instance.ViewModel.IsLoggedIn  = true;
                await AccountAuthHelpers.UpdateUserIsDefault(user, true);

                NavigationService.Navigate(typeof(MainPage));
                //new NavigateToWhatsNewPage().Execute(null);
            }
        }
Exemple #2
0
        public async Task <bool> LoginDefaultUser()
        {
            string errorMessage;

            try
            {
                var defaultUsers = await _udb.GetDefaultUserAccounts();

                if (!defaultUsers.Any())
                {
                    return(false);
                }
                var defaultUser = defaultUsers.First();
                var loginResult = await LoginTest(defaultUser);

                if (loginResult)
                {
                    if (Shell.Instance.ViewModel.CurrentUser != null)
                    {
                        await AccountAuthHelpers.UpdateUserIsDefault(Shell.Instance.ViewModel.CurrentUser);
                    }
                    CurrentUser = defaultUser;
                    IsLoggedIn  = true;
                    return(true);
                    //new NavigateToWhatsNewPage().Execute(null);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception ex)
            {
                errorMessage = ex.Message;
            }

            // Failed to log in with default user, tell them.
            await ResultChecker.SendMessageDialogAsync(errorMessage, false);

            return(false);
        }