public virtual T BuscarPeloId(long id) { using (var context = ProvedorAcesso.Conexao()) { var dbSet = context.Set <T>(); return(dbSet.Where(x => x.Id == id).FirstOrDefault()); } }
public virtual IEnumerable <T> BuscarTudo() { using (var context = ProvedorAcesso.Conexao()) { var dbSet = context.Set <T>(); return(dbSet.ToList()); } }
public virtual bool ExistePeloId(long id) { using (var context = ProvedorAcesso.Conexao()) { var dbSet = context.Set <T>(); return(dbSet.Where(x => x.Id == id).Any()); } }
public virtual bool ExistisByCpf(string cpf) { using (var context = new ProvedorAcesso().Conexao()) { var dbSet = context.Set <Cliente>(); return(dbSet.Where(x => x.Cpf == cpf).Any()); } }
public virtual bool ExistePeloCpfEIdDiferente(long id, string cpf) { using (var context = ProvedorAcesso.Conexao()) { var dbSet = context.Set <Cliente>(); return(dbSet.Where(x => x.Id != id && x.Cpf == cpf).Any()); } }
public virtual void Atualizar(T entity) { using (var context = ProvedorAcesso.Conexao()) { var dbSet = context.Set <T>(); dbSet.Update(entity); context.SaveChanges(); } }
public virtual void Inserir(T entity) { using (var context = ProvedorAcesso.Conexao()) { var dbSet = context.Set <T>(); dbSet.Add(entity); context.SaveChanges(); } }
public virtual void Deletar(T entity) { using (var context = ProvedorAcesso.Conexao()) { var dbSet = context.Set <T>(); var now = DateTime.Now; dbSet.Remove(entity); context.SaveChanges(); } }