private void btnInserirVeic_Click(object sender, RoutedEventArgs e) { bool k; if ((bool)checkBox.IsChecked) { k = true; } else { k = false; } Models.Veiculo v = new Models.Veiculo { id = int.Parse(txtIdVeic.Text), modelo = txtModelo.Text, ano = txtAno.Text, preco = double.Parse(txtPreco.Text), fabricante = Convert.ToString(cmbFabricantes.SelectedValue), situacaoVenda = k }; veiculos.Add(v); lstVeic.Items.Add(v); if (v.situacaoVenda) { lstVeicDisp.Items.Add(v); } else { lstveicVendidos.Items.Add(v); } }
private async void btnInserirVeic_Click(object sender, RoutedEventArgs e) { HttpClient httpClient = new HttpClient(); httpClient.BaseAddress = new Uri(ip); bool k; if ((bool)checkBox.IsChecked) { k = true; } else { k = false; } Models.Veiculo v = new Models.Veiculo { Modelo = txtModelo.Text, Ano = txtAno.Text, Preco = double.Parse(txtPreco.Text), IdFabricante = int.Parse(cmbFabricantes.SelectedValuePath), SituacaoVenda = k }; string s = JsonConvert.SerializeObject(v); var content = new StringContent(s, Encoding.UTF8, "application/json"); await httpClient.PostAsync("/20131011110029/api/veiculo", content); }
private async void btnVender_Click(object sender, RoutedEventArgs e) { HttpClient httpClient = new HttpClient(); httpClient.BaseAddress = new Uri(ip); Models.Veiculo x = (from y in veiculos where y.Id == int.Parse(txtIdVeic.Text) select y).Single(); x.SituacaoVenda = false; var content = new StringContent(JsonConvert.SerializeObject(x), Encoding.UTF8, "application/json"); await httpClient.PutAsync("/20131011110029/api/veiculo/" + x.Id, content); getVeiculos(); }