public void  Inserir(Model.SalaVestibularModel request)
        {
            string        json = JsonConvert.SerializeObject(request);
            StringContent body = new StringContent(json, Encoding.UTF8, "application/json");

            HttpResponseMessage resp = cliente.PostAsync("http://localhost:5000/SalaVestibular/", body).Result;
        }
        public Model.SalaVestibularModel BuscarPorID(int id)
        {
            string json = client.GetAsync("http://localhost:5000/SalaVestibular/" + id).Result.Content.ReadAsStringAsync().Result;

            VerificarErro(json);

            Model.SalaVestibularModel sala = JsonConvert.DeserializeObject <Model.SalaVestibularModel>(json);
            return(sala);
        }
        public void Inserir(Model.SalaVestibularModel modelo)
        {
            string        json = JsonConvert.SerializeObject(modelo);
            StringContent body = new StringContent(json, Encoding.UTF8, "application/json");

            var resp = client.PostAsync("http://localhost:5000/SalaVestibular/", body).Result.Content.ReadAsStringAsync().Result;

            VerificarErro(resp);
        }
        private void btnVestibularAdd_Click(object sender, EventArgs e)
        {
            try
            {
                Model.SalaVestibularModel model = new Model.SalaVestibularModel();


                if (model.IdSalaVestibular == 0)
                {
                    var func = cboVestibularSala.SelectedItem as Model.SalaModel;

                    Model.SalaVestibularModel vestibular = new Model.SalaVestibularModel();
                    vestibular.DsPeriodo = cboPeriodos.Text;
                    vestibular.IdSala    = func.IdSala;


                    Model.SalaModel sala = new Model.SalaModel();
                    sala.NmLocal = cboVestibularInstituicao.Text;
                    sala.NmSala  = cboVestibularSala.Text;

                    Model.SalaVestibularRequest request = new Model.SalaVestibularRequest();
                    request.Vestibular = vestibular;
                    request.Sala       = sala;

                    Nsf.App.API.Client.SalaVestibularAPI api = new App.API.Client.SalaVestibularAPI();
                    api.Inserir(vestibular);

                    MessageBox.Show("Inserido com sucesso.", "NSF", MessageBoxButtons.OK, MessageBoxIcon.Information);

                    this.ListarTudo();
                }
                else if (model.IdSalaVestibular > 0)
                {
                    Model.SalaVestibualrResponse vest = new Model.SalaVestibualrResponse();

                    this.Alterar(vest);
                }
            }
            catch (ArgumentException ex)
            {
                MessageBox.Show(ex.Message, "NSF", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (Exception)
            {
                MessageBox.Show("Ocorreu um erro. Entre em contato com o administrador.", "NSF",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
            }
        }