public static void InserirNoticia(Noticia not) { using (var ctx = new ClassContext()) { ctx.Noticia.Add(not); ctx.SaveChanges(); } }
public static bool InserirPacote(Pacote pct) { using (var ctx = new ClassContext()) { ctx.Pacote.Add(pct); ctx.SaveChanges(); return(true); } }
public static bool InserirProduto(Produto prod) { using (var ctx = new ClassContext()) { ctx.Produto.Add(prod); ctx.SaveChanges(); return(true); } }
public static bool InserirContato(Contato cont) { using (var ctx = new ClassContext()) { ctx.Contato.Add(cont); ctx.SaveChanges(); return(true); } }
public static void ExcluirPacote(int idpacote) { using (var ctx = new ClassContext()) { Pacote pacote = ctx.Pacote.Where(c => c.IDPacote == idpacote).First(); ctx.Pacote.Remove(pacote); ctx.SaveChanges(); } }
public static void ExcluirProduto(int idproduto) { using (var ctx = new ClassContext()) { Produto produto = ctx.Produto.Where(c => c.IDProduto == idproduto).First(); ctx.Produto.Remove(produto); ctx.SaveChanges(); } }
public static void ExcluirContato(int idcontato) { using (var ctx = new ClassContext()) { Contato contato = ctx.Contato.Where(c => c.IDContato == idcontato).First(); ctx.Contato.Remove(contato); ctx.SaveChanges(); } }
public static void ExcluirNoticia(int idnoticia) { using (var ctx = new ClassContext()) { Noticia noticia = ctx.Noticia.Where(n => n.IDNoticia == idnoticia).First(); ctx.Noticia.Remove(noticia); ctx.SaveChanges(); } }
/*EXCLUIR */ public static void ExcluirPessoa(int idpessoa) { using (var ctx = new ClassContext()) { Pessoa pessoa = ctx.Pessoa.Where(p => p.IDPessoa == idpessoa).First(); ctx.Pessoa.Remove(pessoa); ctx.SaveChanges(); } }
//public static bool InseriInvestimento(Investidor i) //{ // using (var ctx = new ClassContext()) // { // List<Investidor> investidor = ctx.Investidor.Where(iv => i.IDInvestidor == i.IDInvestidor).ToList(); // if (investidor.Count == 0) // { // ctx.Investidor.Add(i); // ctx.SaveChanges(); // return true; // } // return false; // } //} public static bool InseriInvestidor(Investidor i) { using (var ctx = new ClassContext()) { ctx.Pessoa.Attach(i.pessoa); ctx.Pacote.Attach(i.pacote); ctx.Investidor.Add(i); ctx.SaveChanges(); return(true); } }
public static void AlterarProduto(Produto prod) { using (var ctx = new ClassContext()) { Produto produto = ctx.Produto.Where(c => c.IDProduto == prod.IDProduto).First(); produto.IDProduto = prod.IDProduto; produto.Titulo = prod.Titulo; produto.Texto = prod.Texto; ctx.SaveChanges(); } }
public static void AlterarPacote(Pacote pct) { using (var ctx = new ClassContext()) { Pacote pacote = ctx.Pacote.Where(c => c.IDPacote == pct.IDPacote).First(); pacote.IDPacote = pct.IDPacote; pacote.Descricao = pct.Descricao; pacote.Valor = pct.Valor; pacote.QtdTotal = pct.QtdTotal; ctx.SaveChanges(); } }
public static void AlterarContato(Contato cont) { using (var ctx = new ClassContext()) { Contato contato = ctx.Contato.Where(c => c.IDContato == cont.IDContato).First(); contato.NomeContato = cont.NomeContato; contato.EmailContato = cont.EmailContato; contato.Mensagem = cont.Mensagem; contato.DataMensagem = cont.DataMensagem; ctx.SaveChanges(); } }
public static void AlterarNoticia(Noticia not) { using (var ctx = new ClassContext()) { Noticia noticia = ctx.Noticia.Where(n => n.IDNoticia == not.IDNoticia).First(); noticia.Titulo = not.Titulo; noticia.Materia = not.Materia; noticia.Image = not.Image; noticia.DataMateria = not.DataMateria; ctx.SaveChanges(); } }
/*ALTERAR */ public static void AlterarPessoa(Pessoa pess) { using (var ctx = new ClassContext()) { Pessoa pessoa = ctx.Pessoa.Where(p => p.IDPessoa == pess.IDPessoa).First(); pessoa.NomeCompleto = pess.NomeCompleto; pessoa.Cpf = pess.Cpf; pessoa.Email = pess.Email; pessoa.Idade = pess.Idade; pessoa.Usuario = pess.Usuario; pessoa.Senha = pess.Senha; ctx.SaveChanges(); } }
/*INSERIR */ public static bool InserirPessoa(Pessoa pess) { using (var ctx = new ClassContext()) { List <Pessoa> pessoa = ctx.Pessoa.Where(p => p.Cpf == pess.Cpf).ToList(); if (pessoa.Count == 0) { ctx.Pessoa.Add(pess); ctx.SaveChanges(); return(true); } return(false); } }