Exemplo n.º 1
0
        public int Update(DTOPerfil perfil)
        {
            int errNumber = 0;

            try
            {
                IDbConnection objConnnexao;
                IDbCommand    objCommand;
                string        sql = "UPDATE tbl_tipocolunista SET tcol_nome = ?tipo WHERE tcol_id = ?codigo";

                //recebendo a conexão e executando o cmd
                objConnnexao = Mapped.Connection();
                objCommand   = Mapped.Command(sql, objConnnexao);

                //atribuindo os parametros da string sql
                objCommand.Parameters.Add(Mapped.Parameter("?codigo", perfil.PerfilId));
                objCommand.Parameters.Add(Mapped.Parameter("?tipo", perfil.Nome));


                objCommand.ExecuteNonQuery();
                objConnnexao.Close();

                //abrindo novamente conexão
                objConnnexao.Dispose();
                objCommand.Dispose();
            }//try
            catch (Exception ex)
            {
                errNumber = -2;
            }

            return(errNumber);
        }//metodo update
Exemplo n.º 2
0
        }//metodo update

        public int Insert(DTOPerfil perfil)
        {
            int errNumber = 0;

            try
            {
                IDbConnection objConexao;
                IDbCommand    objCommand;
                string        sql = "INSERT INTO tbl_tipocolunista(tcol_id, tcol_nome) VALUES (?codigo, ?tipo)";

                //recebendo a conexão e executando o cmd
                objConexao = Mapped.Connection();
                objCommand = Mapped.Command(sql, objConexao);

                //atribuindo os parametros da string sql
                objCommand.Parameters.Add(Mapped.Parameter("?codigo", null));
                objCommand.Parameters.Add(Mapped.Parameter("?tipo", perfil.Nome));

                objCommand.ExecuteNonQuery();
                objConexao.Close();

                //abrindo novamente conexão
                objConexao.Dispose();
                objCommand.Dispose();
            }//try
            catch (Exception ex)
            {
                errNumber = -2;
            }

            return(errNumber);
        }//insert
Exemplo n.º 3
0
        public int InserirColunista(DTOPerfil colunista)
        {
            DALPerfil DALCom = new DALPerfil();

            try
            {
                return(DALCom.Insert(colunista));
            }
            catch (Exception)
            {
                throw;
            }
        }
Exemplo n.º 4
0
        public int AtualizarColunista(DTOPerfil colunista)
        {
            DALPerfil DALCom = new DALPerfil();

            try
            {
                return(DALCom.Update(colunista));
            }
            catch (Exception)
            {
                throw;
            }
        }
Exemplo n.º 5
0
        }//insert

        public List <DTOPerfil> SelectAll()
        {
            List <DTOPerfil> perfis = new List <DTOPerfil>();
            //DTOPerfil perfil = new DTOPerfil();
            List <DTOUsuario> usuarios = new List <DTOUsuario>();

            IDbConnection objConexao;
            IDbCommand    objCommand;
            IDataReader   objDataReader;

            try
            {
                objConexao = Mapped.Connection();
                string sql = "SELECT * FROM tbl_tipocolunista p inner join tbl_colunista u on p.tcol_id = u.tcol_id WHERE u.col_ativo = true";
                objCommand    = Mapped.Command(sql, objConexao);
                objDataReader = objCommand.ExecuteReader();

                while (objDataReader.Read())
                {
                    DTOUsuario usuario = new DTOUsuario();
                    DTOPerfil  perfil  = new DTOPerfil();

                    perfil.PerfilId = Convert.ToInt32(objDataReader["tcol_id"]);
                    perfil.Nome     = Convert.ToString(objDataReader["tcol_nome"]);

                    usuario.UsuarioId = Convert.ToInt32(objDataReader["col_id"]);
                    usuario.Nome      = Convert.ToString(objDataReader["col_nome"]);

                    perfil.Usuarios.Add(usuario);

                    perfis.Add(perfil);
                }

                objConexao.Close();
                objConexao.Dispose();
                objCommand.Dispose();

                return(perfis);
            }
            catch (Exception)
            {
                throw new Exception("Ocorreu um erro ao selecionar os dados de colunistas.");
            }
        }
Exemplo n.º 6
0
        public IList <DTOPerfil> ListarPerfil()
        {
            perfilBM = new BMPerfil();
            IList <DTOPerfil> lstResut = null;

            try
            {
                lstResut = new List <DTOPerfil>();

                foreach (Perfil pf in perfilBM.ObterTodos())
                {
                    DTOPerfil pfdto = new DTOPerfil();
                    CommonHelper.SincronizarDominioParaDTO(pf, pfdto);
                    lstResut.Add(pfdto);
                }
            }
            catch (Exception ex)
            {
                ErroUtil.Instancia.TratarErro(ex);
            }

            return(lstResut);
        }
Exemplo n.º 7
0
        public DTOPerfil Select(int codigo)
        {
            DTOPerfil         perfil   = new DTOPerfil();
            List <DTOUsuario> usuarios = new List <DTOUsuario>();

            IDbConnection objConexao;
            IDbCommand    objComando;
            IDataReader   objDataReader;

            objConexao = Mapped.Connection();
            objComando = Mapped.Command("SELECT * FROM tbl_tipocolunista p inner join tbl_colunista u on p.tcol_id = u.tcol_id WHERE p.tcol_id = ?codigo AND u.col_ativo = true", objConexao);

            objComando.Parameters.Add(Mapped.Parameter("?codigo", codigo));
            objDataReader = objComando.ExecuteReader();
            while (objDataReader.Read())
            {
                DTOUsuario usuario = new DTOUsuario();

                perfil.PerfilId = Convert.ToInt32(objDataReader["tcol_id"]);
                perfil.Nome     = Convert.ToString(objDataReader["tcol_nome"]);

                usuario.UsuarioId = Convert.ToInt32(objDataReader["col_id"]);
                usuario.Nome      = Convert.ToString(objDataReader["col_nome"]);

                perfil.Usuarios.Add(usuario);
            }

            objConexao.Close();
            objDataReader.Close();

            objComando.Dispose();
            objConexao.Dispose();
            objDataReader.Dispose();

            return(perfil);
        }
Exemplo n.º 8
0
        // PUT api/colunista/5
        public int Put(DTOPerfil colunista)
        {
            BLLPerfil BLLobjeto = new BLLPerfil();

            return(BLLobjeto.AtualizarColunista(colunista));
        }
Exemplo n.º 9
0
        // POST api/colunista
        public int Post(DTOPerfil perfil)
        {
            BLLPerfil BLLobjeto = new BLLPerfil();

            return(BLLobjeto.InserirColunista(perfil));
        }