private async void btnConcluirCadastro_Clicked(object sender, EventArgs e) { Model.Pets pet = new Model.Pets(); pet.Nome = entryNome.Text; pet.Raca = entryRaca.Text; pet.Especie = entryTipo.Text; pet.Idade = entryIdade.Text; pet.Tamanho = (string)pickerTamanho.SelectedItem; pet.Peso = (string)pickerPeso.SelectedItem; pet.Genero = (string)pickerGenero.SelectedItem; pet.Descricao = editorDescricao.Text; pet.ClientePessoaEmail = Login.UsuarioAtivo.UsuarioEmail; pet.ClientePessoa = Login.UsuarioAtivo; pet.ClientePessoa.Usuario = Login.UsuarioAtivo.Usuario; Controller.Mascotes.Adicionar adicionar = new Controller.Mascotes.Adicionar(); await adicionar.Add(pet); Login logar = new Login(); await logar.GetUsuariotAsync(); //Navigation.InsertPageBefore(paginaLogin, this); //App.Current.MainPage = new NavigationPage(new Pets.MostrarPetsForm()); await PilhaDeNavegacao.Navegacao.PopAsync(); //await Navigation.PushModalAsync(new Pets.MostrarPetsForm()); }
public async Task <String> Add(Model.Pets pet) { var json = JsonConvert.SerializeObject(pet, new JsonSerializerSettings() { ReferenceLoopHandling = ReferenceLoopHandling.Ignore }); var content = new StringContent(json, Encoding.UTF8, "application/json"); HttpResponseMessage response = null; Model.Token.TokenDeCancelamento tokenDeCancelamento = new Model.Token.TokenDeCancelamento(); response = await client.PostAsync(Constants.URIPet, content, tokenDeCancelamento.getCancellationToken()); if (response.IsSuccessStatusCode) { return("Pet cadastrado com sucesso"); } else { string resposta = response.Content.ReadAsStringAsync().Result; return(resposta); } }