public List <Telefones> RetornarPorContato(int contato) { using (ISession session = FluentySessionFactory.AbrirSession()) { return((from e in session.Query <Telefones>() where e.id_contatos == contato select e).ToList()); } }
public bool ValidaLogin(string login) { using (ISession session = FluentySessionFactory.AbrirSession()) { return((from e in session.Query <Usuarios>() where e.login.Equals(login) select e).Count() > 0); } }
public IList <T> Consultar() { using (ISession session = FluentySessionFactory.AbrirSession()) { return((from e in session.Query <T>() select e).ToList()); } }
public IList <T> Consultar(Expression <Func <T, bool> > where) { using (ISession session = FluentySessionFactory.AbrirSession()) { return(session.Query <T>().Where <T>(where).ToList()); } }
public bool validarTelefone(int telefone) { using (ISession sesseion = FluentySessionFactory.AbrirSession()) { return((from e in sesseion.Query <Telefone>() where e.telefone.Equals(telefone) select e).Count() > 0); } }
public T RetornarPorId(int id) { using (ISession session = FluentySessionFactory.AbrirSession()) { return(session.Get <T>(id)); } }
public bool validarContato(string nome) { using (ISession session = FluentySessionFactory.AbrirSession()) { return((from e in session.Query <Contato>() where e.nome.Equals(nome) && e.status.Equals("A") select e).Count() > 0); } }
public void Excluir(T entidade) { using (ISession session = FluentySessionFactory.AbrirSession()) { using (ITransaction transacao = session.BeginTransaction()) { try { session.Delete(entidade); transacao.Commit(); } catch (Exception ex) { throw new Exception("Erro ao deletar" + ex.Message); } } } }
public void Alterar(T entidade) { using (ISession session = FluentySessionFactory.AbrirSession()) { using (ITransaction transacao = session.BeginTransaction()) { try { session.Update(entidade); transacao.Commit(); } catch (Exception ex) { throw new Exception("Erro ao atualizar" + ex.Message); } } } }
public void Inserir(T entidade) { using (ISession session = FluentySessionFactory.AbrirSession()) { using (ITransaction transacao = session.BeginTransaction()) { try { session.Save(entidade); transacao.Commit(); } catch (Exception ex) { if (!transacao.WasCommitted) { throw new Exception("Erro ao inserir" + ex.Message); } } } } }
public void Excluir(T entidade) { using (ISession session = FluentySessionFactory.AbrirSession()) { using (ITransaction transacao = session.BeginTransaction()) { try { session.Delete(entidade); transacao.Commit(); } catch (Exception ex) { if (!transacao.WasCommitted) { transacao.Rollback(); } throw new Exception("Erro ao excluir entidade: " + ex.Message); } } } }