Exemplo n.º 1
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);
        }
Exemplo n.º 2
0
        private async Task CreateUserAction(User user)
        {
            if (!user.AcceptedTerms)
            {
                await Shell.Current.DisplayAlert("Atenção", "Favor aceitar o termo de conduta.", "OK");

                return;
            }

            _apiResponse = _userClient.Add(user);
            if (!_apiResponse.IsSuccess)
            {
                await App.Current.MainPage.DisplayAlert("Falha", _apiResponse.Message, "OK");

                return;
            }

            var userCustomConfig = new UserCustomConfigurationApp();

            userCustomConfig.GuidKey                 = _apiResponse.Data.GuidKey.ToString();
            userCustomConfig.IsFirstAccess           = false;
            userCustomConfig.IsLoggedIn              = true;
            userCustomConfig.LastPasswordOnThisPhone = _apiResponse.Data.Password;
            _appCustomConfigurationViewModel.SaveUserCustomConfigAsync(userCustomConfig);

            await CreateAccount();
        }
Exemplo n.º 3
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.º 4
0
        private async Task RefreshCommandAction()
        {
            _loadedConfigs = _configurationViewModel.LoadUserCustomConfigurationApp();

            FillUserPosts_old();
            IsBusy = false;
        }
Exemplo n.º 5
0
        public AppShell()
        {
            InitializeComponent();

            BindingContext = configurationViewModel = DependencyService.Get <AppCustomConfigurationViewModel>(DependencyFetchTarget.GlobalInstance);
            _loadedConfigs = configurationViewModel.LoadUserCustomConfigurationApp();

            StartApp();
        }
Exemplo n.º 6
0
        public AccountViewModel()
        {
            _apiResponse = new ApiResponse <Account>();

            _accountClient = new AccountClient();

            _mediaProvider = new MediaProvider();
            _appCustomConfigurationViewModel = DependencyService.Get <AppCustomConfigurationViewModel>();
            _loadedConfigs = _appCustomConfigurationViewModel.LoadUserCustomConfigurationApp();

            TakePictureCommand = new Command <Account>(async(accountParms) => await TakePictureAction());
            LoadPictureCommand = new Command <Account>(async(accountParms) => await LoadPictureAction());
            SaveCommand        = new Command <Account>(async(accountParms) => await SaveAction());

            LoadAccount();
        }