Ejemplo n.º 1
0
        private async void btnDeletar_Click(object sender, RoutedEventArgs e)
        {
            Models.Escola obj        = (Models.Escola)lvEscolasDel.SelectedItem;
            HttpClient    httpClient = new HttpClient();

            httpClient.BaseAddress = new Uri(ip);
            await httpClient.DeleteAsync("/api/escola/" + obj.Id.ToString());
        }
Ejemplo n.º 2
0
        private async void btnEditar_Click(object sender, RoutedEventArgs e)
        {
            HttpClient httpClient = new HttpClient();

            httpClient.BaseAddress = new Uri(ip);
            Models.Escola esc = new Models.Escola
            {
                Nome              = txtNomeEdit.Text,
                UF                = txtUFEdit.Text,
                CienciasNatureza  = Convert.ToDouble(txtNatEdit.Text),
                CienciasHumanas   = Convert.ToDouble(txtHumEdit.Text),
                LinguagensCodigos = Convert.ToDouble(txtLingEdit.Text),
                Matematica        = Convert.ToDouble(txtMatEdit.Text),
                Redacao           = Convert.ToDouble(txtRedEdit.Text),
            };
            string s       = "=" + JsonConvert.SerializeObject(esc);
            var    content = new StringContent(s, Encoding.UTF8, "application/x-www-form-urlencoded");
            await httpClient.PutAsync("/api/escola/" + f.Id, content);
        }
Ejemplo n.º 3
0
        private async void btnInserir_Click(object sender, RoutedEventArgs e)
        {
            HttpClient httpClient = new HttpClient();

            httpClient.BaseAddress = new Uri(ip);

            Models.Escola escola = new Models.Escola();
            escola.Nome              = txtNome.Text;
            escola.UF                = txtUF.Text;
            escola.CienciasNatureza  = Convert.ToDouble(txtNaturezas.Text);
            escola.CienciasHumanas   = Convert.ToDouble(txtHumanas.Text);
            escola.LinguagensCodigos = Convert.ToDouble(txtLinguagens.Text);
            escola.Matematica        = Convert.ToDouble(txtMat.Text);
            escola.Redacao           = Convert.ToDouble(txtRedacao.Text);

            escolasList.Add(escola);

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