private async Task ExecuteRegisterCommand() { //if (IsBusy) // return; IsLoading = true; App.IsUsuarioLogado = false; App.ApiToken = string.Empty; try { if (this.IsViewModelValid()) { Dictionary <string, string> dictionaryRegister = new Dictionary <string, string>(); dictionaryRegister.Add("tipoApp", App.CurrentTipoApp.ToString()); dictionaryRegister.Add("email", UsuarioModel.Email); dictionaryRegister.Add("senha", UsuarioModel.Senha); dictionaryRegister.Add("confirmacaoSenha", ConfirmacaoSenha); dictionaryRegister.Add("cnpj", UsuarioModel.PessoaJuridicaModel.CNPJ); dictionaryRegister.Add("razaoSocial", UsuarioModel.PessoaJuridicaModel.RazaoSocial); RestService = new UsuarioRestService("auth/register"); this.ResponseViewModel = RestService.GenericSend(dictionaryRegister).Result; } } catch (InvalidViewModelException ex) { this.ResponseViewModel.HasError = true; this.ResponseViewModel.ErrorMessage = ex.Message; } catch (Exception ex) { this.ResponseViewModel.HasError = true; this.ResponseViewModel.ErrorMessage = ex.Message; } finally { IsLoading = false; } }
private async Task ExecuteLoginCommand() { IsLoading = true; App.IsUsuarioLogado = false; App.ApiToken = string.Empty; try { if (this.IsViewModelValid()) { Dictionary <string, string> dictionaryRegister = new Dictionary <string, string>(); dictionaryRegister.Add("tipoApp", App.CurrentTipoApp.ToString()); dictionaryRegister.Add("email", UsuarioModel.Email); dictionaryRegister.Add("senha", UsuarioModel.Senha); RestService = new UsuarioRestService("auth/login"); this.ResponseViewModel = RestService.GenericSend(dictionaryRegister).Result; //UsuarioModel usuarioEncontrado = await DataStore.GetAsync((o) => o.Email.Equals(UsuarioModel.Email) && o.Senha.Equals(UsuarioModel.Senha)); //App.IsUsuarioLogado = usuarioEncontrado != null; } } catch (InvalidViewModelException ex) { this.ResponseViewModel.HasError = true; this.ResponseViewModel.ErrorMessage = ex.Message; } catch (Exception ex) { this.ResponseViewModel.HasError = true; this.ResponseViewModel.ErrorMessage = ex.Message; } finally { IsLoading = false; } }