Client Rest + WPF - PUT Method (UPDATE)

1

Hello everyone! I'm trying to implement a method to update (update) information in a WPF application. Apparently, everything is correct, however, the method does not work. Here is the code:

This is the PUT on the server side (Controller):

public void Put(int id, [FromBody] string value)
        {
            Models.lok x = JsonConvert.DeserializeObject
                <Models.lok>(value);
            Models.PatDataContext dc = new Models.PatDataContext();
            Models.lok rsk = (from r in dc.Registras
                                           where r.id == id
                                           select r).Single();
            rsk.nome = x.nome;
            rsk.observacao = x.observacao;
            dc.SubmitChanges();
        }

And this is what's on the client:

private async void btnAlterar_Click(object sender, RoutedEventArgs e)
        {
            HttpClient httpClient = new HttpClient();
            httpClient.BaseAddress = new Uri(http://localhost:60417/);

            Modelo.Jos sa = new Modelo.Jos
            {
                Id = int.Parse(textBoxID.Text),
                Nome = textBoxNome.Text,
                Observacao = textBoxObs.Text
            };

            string seria = "=" + JsonConvert.SerializeObject(sa);
            var content = new StringContent(seria, Encoding.UTF8, "application/x-www-form-urlencoded");
            await httpClient.PutAsync("/api/Jos" + sa.Id, content);
        }

Thank you!

    
asked by anonymous 18.08.2016 / 17:22

0 answers