public List <Models.Usuario> Listar() { Models.IFZAPDataContext dc = new Models.IFZAPDataContext(); var usuarios = from u in dc.Usuarios select u; return(usuarios.ToList()); }
public List <Models.Grupo> Listar() { Models.IFZAPDataContext dc = new Models.IFZAPDataContext(); var grupos = from u in dc.Grupos select u; return(grupos.ToList()); }
public void Deletar(string descricao) { Models.IFZAPDataContext dc = new Models.IFZAPDataContext(); var grupo = (from u in dc.Grupos where u.Descricao == descricao select u).Single(); dc.Grupos.DeleteOnSubmit(grupo); dc.SubmitChanges(); }
public void Criar([FromBody] string conteudo) { Models.IFZAPDataContext dc = new Models.IFZAPDataContext(); var grupo = JsonConvert.DeserializeObject <Models.Grupo>(conteudo); dc.Grupos.InsertOnSubmit(grupo); dc.SubmitChanges(); }
public void Deletar(int id) { Models.IFZAPDataContext dc = new Models.IFZAPDataContext(); var usuario = (from u in dc.Usuarios where u.Id == id select u).Single(); dc.Usuarios.DeleteOnSubmit(usuario); dc.SubmitChanges(); }
public void Alterar(int id, [FromBody] string conteudo) { Models.IFZAPDataContext dc = new Models.IFZAPDataContext(); var grupo = JsonConvert.DeserializeObject <Models.Grupo>(conteudo); var r = (from u in dc.Grupos where u.Id == id select u).Single(); r = grupo; dc.SubmitChanges(); }
public void Alterar(string nome, [FromBody] string conteudo) { Models.IFZAPDataContext dc = new Models.IFZAPDataContext(); var usuario = JsonConvert.DeserializeObject <Models.Usuario>(conteudo); var r = (from u in dc.Usuarios where u.Nome == nome select u).Single(); r = usuario; dc.SubmitChanges(); }
public string ConsultarPorNome(string descricao) { Models.IFZAPDataContext dc = new Models.IFZAPDataContext(); try { var r = (from u in dc.Grupos where u.Descricao == descricao select u.Descricao).Single(); return(r); } catch (Exception) { return(null); } }
public string ConsultarPorNome(string nome) { Models.IFZAPDataContext dc = new Models.IFZAPDataContext(); try { var r = (from u in dc.Usuarios where u.Nome == nome select u.Nome).Single(); return(r); } catch (Exception) { return(null); } }
public List <Models.Usuario> ListarMembros(string grupoDescricao) { Models.IFZAPDataContext dc = new Models.IFZAPDataContext(); int grupoId = (from g in dc.Grupos where g.Descricao == grupoDescricao select g.Id).Single(); var membros = from m in dc.Membros where m.Grupo_Id == grupoId select m; List <Models.Usuario> rMembros = new List <Models.Usuario>(); foreach (var item in membros) { var membro = (from u in dc.Usuarios where u.Id == item.Usuario_Id select u).Single(); rMembros.Add(membro); } return(rMembros); }