예제 #1
0
 public IEnumerable <UsuarioEFilial> GetAllUsuario()
 {
     try
     {
         using (DbConnection conexao = FactoryConexao.getConnection(this.infConnection))
         {
             return(conexao.Query <UsuarioEFilial>("SELECT u.*, f.sigla siglaFilial FROM votacao.filial f INNER JOIN votacao.usuario u ON(u.idfilial = f.id)"));
         }
     }
     catch (DbException ex)
     {
         throw ex;
     }
 }
예제 #2
0
 public Filial GetFilialById(string id)
 {
     try
     {
         using (DbConnection conexao = FactoryConexao.getConnection(this.infConnection))
         {
             return(conexao.QueryFirstOrDefault <Filial>(string.Format("select  * from {0} where id={1}id ", nomeTabela, caracter), new { id = Guid.Parse(id) }));
         }
     }
     catch (DbException ex)
     {
         throw ex;
     }
 }
예제 #3
0
 public void UpdateUsuario(Usuario usuario)
 {
     try
     {
         using (DbConnection conexao = FactoryConexao.getConnection(this.infConnection))
         {
             conexao.Execute(sqlUpdate, usuario);
         }
     }
     catch (DbException ex)
     {
         throw ex;
     }
 }
예제 #4
0
 public IEnumerable <T> FindAll()
 {
     try
     {
         using (DbConnection conexao = FactoryConexao.getConnection(this.infConnection))
         {
             return(conexao.Query <T>(string.Format("select  * from {0}", nomeTabela)));
         }
     }
     catch (NpgsqlException ex)
     {
         throw ex;
     }
 }
예제 #5
0
 public Usuario GetUsuarioByEmail(string email)
 {
     try
     {
         using (DbConnection conexao = FactoryConexao.getConnection(this.infConnection))
         {
             return(conexao.QueryFirstOrDefault <Usuario>(string.Format("select  * from {0} where email={1}email ", nomeTabela, caracter), new { email = email }));
         }
     }
     catch (DbException ex)
     {
         throw ex;
     }
 }
예제 #6
0
 public void Create(T entity)
 {
     try
     {
         using (DbConnection conexao = FactoryConexao.getConnection(this.infConnection))
         {
             conexao.Execute(sqlInsert, entity);
         }
     }
     catch (NpgsqlException ex)
     {
         throw ex;
     }
 }
예제 #7
0
 public Usuario GetByUsuario(string email, string senha)
 {
     try
     {
         using (DbConnection conexao = FactoryConexao.getConnection(this.infConnection))
         {
             return(conexao.QueryFirstOrDefault <Usuario>(string.Format("select  * from {0} " +
                                                                        " where email={1}email and senha={1}senha ", nomeTabela, caracter), new { email = email, senha = senha }));
         }
     }
     catch (DbException ex)
     {
         throw ex;
     }
 }
예제 #8
0
 public void Delete(T entity)
 {
     try
     {
         Entities.Models.IEntity entidade = (Entities.Models.IEntity)entity;
         using (DbConnection conexao = FactoryConexao.getConnection(this.infConnection))
         {
             conexao.Execute(string.Format("delete from {0} where id={1}id", nomeTabela, caracter), new { id = entidade.id });
         }
     }
     catch (NpgsqlException ex)
     {
         throw ex;
     }
 }
예제 #9
0
 public IEnumerable <VotacaoDoRecurso> GetVotosDoUsuario(string idUsuario)
 {
     try
     {
         using (DbConnection conexao = FactoryConexao.getConnection(this.infConnection))
         {
             return(conexao.Query <VotacaoDoRecurso>(string.Format("select * from {0} where idUsuario={1}idUsuario ",
                                                                   nomeTabela, caracter), new { idUsuario = Guid.Parse(idUsuario) }));
         };
     }
     catch (DbException ex)
     {
         throw ex;
     }
 }
예제 #10
0
 public Filial GetFilialBySiglaENome(string sigla, string nome)
 {
     try
     {
         using (DbConnection conexao = FactoryConexao.getConnection(this.infConnection))
         {
             return(conexao.QueryFirstOrDefault <Filial>(string.Format("select  * from {0} " +
                                                                       " where upper(sigla)={1}sigla and upper(nome)={1}nome ",
                                                                       nomeTabela, caracter),
                                                         new { sigla = sigla.ToUpper(), nome = nome.ToUpper() }));
         }
     }
     catch (DbException ex)
     {
         throw ex;
     }
 }
예제 #11
0
        public IEnumerable <Entities.BO.RecursoParaVotacao> GetRecursosNaoVotados(string idusuario)
        {
            try
            {
                using (DbConnection conexao = FactoryConexao.getConnection(this.infConnection))
                {
                    var query = string.Format("SELECT * FROM {0} WHERE id NOT IN (SELECT idrecurso FROM votacao.votacaodorecurso  WHERE idusuario ={1}idusuario)", nomeTabela, caracter);


                    return(conexao.Query <Entities.BO.RecursoParaVotacao>(query, new { idusuario = Guid.Parse(idusuario) }));
                };
            }
            catch (DbException ex)
            {
                throw ex;
            }
        }
예제 #12
0
 public VotacaoDoRecurso GetVotacaoDoRecursoByFilialUsuarioERecurso(string idFilial, string idUsuario, string idRecurso)
 {
     try
     {
         using (DbConnection conexao = FactoryConexao.getConnection(this.infConnection))
         {
             return(conexao.QueryFirstOrDefault <VotacaoDoRecurso>(string.Format("select * from {0} " +
                                                                                 " where idFilial={1}idFilial and idUsuario={1}idUsuario and idRecurso={1}idRecurso ",
                                                                                 nomeTabela, caracter), new { id = Guid.Parse(idFilial),
                                                                                                              idUsuario = Guid.Parse(idUsuario),
                                                                                                              idRecurso = Guid.Parse(idRecurso) }));
         };
     }
     catch (DbException ex)
     {
         throw ex;
     }
 }