public void Delete(int id)
 {
     Models.AgendaDataContext dc = new Models.AgendaDataContext();
     Models.Contato           c  = (from f in dc.Contatos where f.Id == id select f).Single();
     dc.Contatos.DeleteOnSubmit(c);
     dc.SubmitChanges();
 }
 public void Put(int id, [FromBody] Models.Contato contato)
 {
     Models.AgendaDataContext dc   = new Models.AgendaDataContext();
     Models.Contato           cont = (from f in dc.Contatos where f.Id == id select f).Single();
     cont.Nome     = contato.Nome;
     cont.Telefone = contato.Telefone;
     dc.SubmitChanges();
 }
Example #3
0
        // POST api/agenda
        public void Post([FromBody] string value)
        {
            List <Models.Compromisso> x = JsonConvert.DeserializeObject
                                          <List <Models.Compromisso> >(value);

            Models.AgendaDataContext dc = new Models.AgendaDataContext();
            dc.Compromissos.InsertAllOnSubmit(x);
            dc.SubmitChanges();
        }
 public void Post([FromBody] Models.Contato contato)
 {
     Models.AgendaDataContext dc = new Models.AgendaDataContext();
     dc.Contatos.InsertOnSubmit(new Models.Contato()
     {
         Nome = contato.Nome, Telefone = contato.Telefone
     });
     dc.SubmitChanges();
 }
Example #5
0
 // PUT api/agenda/5
 public void Put(int id, [FromBody] string value)
 {
     Models.Compromisso x = JsonConvert.DeserializeObject
                            <Models.Compromisso>(value);
     Models.AgendaDataContext dc   = new Models.AgendaDataContext();
     Models.Compromisso       comp = (from f in dc.Compromissos
                                      where f.Id == id
                                      select f).Single();
     comp.Descricao = x.Descricao;
     comp.Local     = x.Local;
     comp.Data      = x.Data;
     comp.Realizado = x.Realizado;
     dc.SubmitChanges();
 }