Beispiel #1
0
 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);
     }
 }
Beispiel #3
0
 public IList <T> Consultar()
 {
     using (ISession session = FluentySessionFactory.AbrirSession())
     {
         return((from e in session.Query <T>() select e).ToList());
     }
 }
Beispiel #4
0
 public IList <T> Consultar(Expression <Func <T, bool> > where)
 {
     using (ISession session = FluentySessionFactory.AbrirSession())
     {
         return(session.Query <T>().Where <T>(where).ToList());
     }
 }
Beispiel #5
0
 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);
     }
 }
Beispiel #6
0
 public T RetornarPorId(int id)
 {
     using (ISession session = FluentySessionFactory.AbrirSession())
     {
         return(session.Get <T>(id));
     }
 }
Beispiel #7
0
 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);
     }
 }
Beispiel #8
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);
             }
         }
     }
 }
Beispiel #9
0
 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);
             }
         }
     }
 }
Beispiel #10
0
 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);
                 }
             }
         }
     }
 }
Beispiel #11
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)
             {
                 if (!transacao.WasCommitted)
                 {
                     transacao.Rollback();
                 }
                 throw new Exception("Erro ao excluir entidade: " + ex.Message);
             }
         }
     }
 }