Exemplo n.º 1
0
        private async Task LoginAction(User user)
        {
            user.GuidKey = GuidGenerate.USER_ID;
            _apiResponse = _userClient.Login(user);
            if (_apiResponse.Data == null)
            {
                await App.Current.MainPage.DisplayAlert("Falha", _apiResponse.Message, "OK");

                return;
            }

            if (user.RememberMe)
            {
                var userCustomConfig = new UserCustomConfigurationApp();
                userCustomConfig.GuidKey                 = _apiResponse.Data.GuidKey.ToString();
                userCustomConfig.IsFirstAccess           = false;
                userCustomConfig.LastPasswordOnThisPhone = _apiResponse.Data.Password;
                _appCustomConfigurationViewModel.SaveUserCustomConfigAsync(userCustomConfig);
            }

            // verifica se existe uma conta, se não existir, chama a página para realizar a criação da conta
            var _apiAccountResponse = _accountClient.GetByObj(new Account()
            {
                UserIdenti = _apiResponse.Data.UserIdenti
            });

            if (_apiAccountResponse.Data == null)
            {
                await CreateAccount();
            }
            else
            {
                await App.Current.MainPage.Navigation.PopModalAsync();
            }
        }
Exemplo n.º 2
0
        private async Task SaveAction()
        {
            if (Account.AccountIdenti == 0)
            {
                _apiResponse = _accountClient.Add(Account);
            }
            else
            {
                _apiResponse = _accountClient.Update(Account);
            }

            if (!_apiResponse.IsSuccess)
            {
                await Shell.Current.DisplayAlert("Erro", _apiResponse.Message, "OK");

                return;
            }

            var userCustomConfig = new UserCustomConfigurationApp();

            userCustomConfig.IsLoggedIn              = true;
            userCustomConfig.IsFirstAccess           = false;
            userCustomConfig.GuidKey                 = _apiResponse.Data.GuidKey.ToString();
            userCustomConfig.LastUserNameOnThisPhone = _apiResponse.Data.User.Name;
            _appCustomConfigurationViewModel.SaveUserCustomConfigAsync(userCustomConfig);
        }