Exemplo n.º 1
0
        private async void TryToPerformAutoLogin()
        {
            CredentialService CService = MvvmNanoIoC.Resolve <CredentialService>();

            try
            {
                if (CService.DoCredentialsExist())
                {
                    CheckAuthentication auth = new CheckAuthentication();
                    auth.authentication          = new Authentication();
                    auth.authentication.password = CService.Password;
                    auth.authentication.userName = CService.UserName;



                    bool result = await IsValidAuthentication(auth);

                    if (result)
                    {
                        MvvmNanoIoC.RegisterAsSingleton <Authentication>(auth.authentication);
                        SetUpMainPage <MasterDetailViewModel>();
                    }
                    else
                    {
                        SetUpMainPage <LoginViewModel>();
                    }
                }
                else
                {
                    SetUpMainPage <LoginViewModel>();
                }
            }
            catch (Exception)
            {
                SetUpMainPage <LoginViewModel>();
            }
        }