コード例 #1
0
        private async void buttonUpdate_Click(object sender, RoutedEventArgs e)
        {
            HttpClient httpClient = new HttpClient();

            httpClient.BaseAddress = new Uri(ip);
            Models.Veiculo f = new Models.Veiculo
            {
                Id     = int.Parse(txtId.Text),
                Modelo = txtDesc.Text
            };

            string s = "=" + JsonConvert.SerializeObject(f);

            var content = new StringContent(s, Encoding.UTF8, "application/x-www-form-urlencoded");

            await httpClient.PutAsync("/20131011110029/api/veiculo/" + f.Id, content);
        }
コード例 #2
0
        private async void buttonInserir_Click(object sender, RoutedEventArgs e)
        {
            HttpClient httpClient = new HttpClient();

            httpClient.BaseAddress = new Uri(ip);
            Models.Veiculo f = new Models.Veiculo
            {
                Id           = int.Parse(txtId1.Text),
                Modelo       = txtModelo.Text,
                idFabricante = int.Parse(cbox.SelectedValue.ToString())
            };
            List <Models.Veiculo> fl = new List <Models.Veiculo>();

            fl.Add(f);
            string s       = "=" + JsonConvert.SerializeObject(fl);
            var    content = new StringContent(s, Encoding.UTF8, "application/x-www-form-urlencoded");
            await httpClient.PostAsync("/20131011110029/api/veiculo", content);
        }