public void Criar([FromBody] string conteudo)
 {
     Models.WhatsappDataContext dataContext = new Models.WhatsappDataContext();
     Models.Grupo grupo = JsonConvert.DeserializeObject <Models.Grupo>(conteudo);
     dataContext.Grupos.InsertOnSubmit(grupo);
     dataContext.SubmitChanges();
 }
        public void Deletar(string nome)
        {
            Models.WhatsappDataContext dc = new Models.WhatsappDataContext();
            var r = (from u in dc.Usuarios
                     where u.nome == nome
                     select u).Single();

            dc.Usuarios.DeleteOnSubmit(r);
            dc.SubmitChanges();
        }
 public void AlterarUri(string nome, [FromBody] string conteudo)
 {
     Models.Usuario             usuario = JsonConvert.DeserializeObject <Models.Usuario>(conteudo);
     Models.WhatsappDataContext dc      = new Models.WhatsappDataContext();
     Models.Usuario             r       = (from u in dc.Usuarios
                                           where u.nome == nome
                                           select u).Single();
     r.uri = usuario.uri;
     dc.SubmitChanges();
 }
 public void Alterar(int id, [FromBody] string conteudo)
 {
     Models.WhatsappDataContext dataContext = new Models.WhatsappDataContext();
     Models.Grupo grupo   = JsonConvert.DeserializeObject <Models.Grupo>(conteudo);
     Models.Grupo grupoBD = (from g in dataContext.Grupos
                             where g.id == id
                             select g).Single();
     grupoBD.descricao = grupo.descricao;
     dataContext.SubmitChanges();
 }
        public void Deletar(int id)
        {
            Models.WhatsappDataContext dc = new Models.WhatsappDataContext();
            var r = (from g in dc.Grupos
                     where g.id == id
                     select g).Single();

            var membros = from m in dc.GrupoUsuarios
                          where m.grupo_id == r.id
                          select m;

            dc.GrupoUsuarios.DeleteAllOnSubmit(membros);
            dc.Grupos.DeleteOnSubmit(r);
            dc.SubmitChanges();
        }
Beispiel #6
0
 public void Deletar(Models.GrupoUsuario membro)
 {
     Models.WhatsappDataContext dataContext = new Models.WhatsappDataContext();
     dataContext.GrupoUsuarios.DeleteOnSubmit(membro);
     dataContext.SubmitChanges();
 }