Exemple #1
0
        private async Task ExecuteLoginCommand()
        {
            bool isLoginSuccess = false;

            if (IsBusy)
            {
                return;
            }

            IsBusy = true;
            loginCommand.ChangeCanExecute();

            try
            {
                isLoginSuccess = await cpFeeds.GetAccessToken(this.UserName, this.Password);
            }
            catch (Exception ex)
            {
                isLoginSuccess = false;
            }

            finally
            {
                IsBusy = false;
                loginCommand.ChangeCanExecute();
            }

            if (isLoginSuccess)
            {
                await page.Navigation.PushModalAsync(new RootPage());

                if (Device.OS == TargetPlatform.Android)
                {
                    Application.Current.MainPage = new RootPage();
                }
            }
            else
            {
                await page.DisplayAlert("Login Erro", "Login Erro! por favor tente novamente", "Ok");
            }
        }