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; } }
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; } }
public void UpdateUsuario(Usuario usuario) { try { using (DbConnection conexao = FactoryConexao.getConnection(this.infConnection)) { conexao.Execute(sqlUpdate, usuario); } } catch (DbException ex) { throw ex; } }
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; } }
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; } }
public void Create(T entity) { try { using (DbConnection conexao = FactoryConexao.getConnection(this.infConnection)) { conexao.Execute(sqlInsert, entity); } } catch (NpgsqlException ex) { throw ex; } }
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; } }
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; } }
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; } }
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; } }
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; } }
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; } }