Exemplo n.º 1
0
        public TipoDTO ObterPorPK(TipoDTO dto)
        {
            try
            {
                ComandText = "stp_GER_TIPO_OBTERPORPK";

                AddParameter("CODIGO", dto.Codigo);

                MySqlDataReader dr = ExecuteReader();

                dto = new TipoDTO();

                if (dr.Read())
                {
                    dto.Codigo    = int.Parse(dr[0].ToString());
                    dto.Descricao = dr[1].ToString();
                    dto.Sigla     = dr[2].ToString();
                    dto.Estado    = int.Parse(dr[3].ToString());
                    dto.Operacao  = dr[4].ToString();
                }
            }
            catch (Exception ex)
            {
                dto.Sucesso      = false;
                dto.MensagemErro = ex.Message.Replace("'", "");
            }
            finally
            {
                FecharConexao();
            }

            return(dto);
        }
Exemplo n.º 2
0
        public TipoDTO Alterar(TipoDTO dto)
        {
            try
            {
                ComandText = "stp_GER_TIPO_ALTERAR";
                AddParameter("DESCRICAO", dto.Descricao);
                AddParameter("SIGLA", dto.Sigla);
                AddParameter("SITUACAO", dto.Estado);
                AddParameter("CODIGO", dto.Codigo);
                AddParameter("@TIPO", dto.Operacao);

                dto.Codigo  = ExecuteNonQuery();
                dto.Sucesso = true;
            }
            catch (Exception ex)
            {
                dto.Sucesso      = false;
                dto.MensagemErro = ex.Message.Replace("'", "");
            }
            finally
            {
                FecharConexao();
            }

            return(dto);
        }
Exemplo n.º 3
0
 public void AtualizarTipo(string idTipo, TipoDTO tipoNew)
 {
     if ((idTipo != null) && (tipoNew != null))
     {
         _tipoDAO.AtualizarTipo(idTipo, tipoNew);
     }
     this.Mensagem = "Falha na execucao do metodo AtualizarTipo() BLL";
 }
Exemplo n.º 4
0
 public void Cadastrar(TipoDTO tipoDTO)
 {
     if (Consultar(tipoDTO) == null)
     {
         DataContext.Tipos.Add(Conversor.Mapear(tipoDTO));
         DataContext.SaveChanges();
     }
 }
Exemplo n.º 5
0
        public void AdicionarNovoTipo(TipoDTO tipo)
        {
            if ((tipo != null) && (tipo.DescricaoTipo != null))
            {
                _tipoDAO.AdicionarNovoTipo(tipo);
            }

            this.Mensagem = "Falha na execucao do metodo AdicionarNovoTipo() BLL";
        }
 internal static Tipo Mapear(TipoDTO tipo)
 {
     return(tipo != null ? new Tipo()
     {
         Codigo = tipo.Codigo,
         Nome = tipo.Nome,
         Extensao = tipo.Extensao,
         Tipodeexecucao = (int)tipo.TipoExecucao
     } : null);
 }
Exemplo n.º 7
0
 public TipoDTO Salvar(TipoDTO dto)
 {
     if (dto.Codigo > 0)
     {
         return(dao.Alterar(dto));
     }
     else
     {
         return(dao.Adicionar(dto));
     }
 }
Exemplo n.º 8
0
 public IActionResult AtualizarTipo(string idTipo, TipoDTO tipoNew)
 {
     try
     {
         _tipoBll.AtualizarTipo(idTipo, tipoNew);
         return(Ok());
     }
     catch (System.Exception ex)
     {
         return(BadRequest(ex));
     }
 }
Exemplo n.º 9
0
 public ActionResult <Tipo> AdicionarNovoTipo(TipoDTO tipo)
 {
     try
     {
         _tipoBll.AdicionarNovoTipo(tipo);
         return(Ok());
     }
     catch (System.Exception ex)
     {
         return(BadRequest(ex));
     }
 }
Exemplo n.º 10
0
        public void AdicionarNovoTipo(TipoDTO tipo)
        {
            if (tipo != null)
            {
                Tipo tipoNovo = new Tipo {
                    DescricaoTipo = tipo.DescricaoTipo.ToUpper()
                };

                _context.CollectionTipo.InsertOne(tipoNovo);
            }

            this.Mensagem = "Falha ao executar o metodo AdicionarNovoTipo() DAO";
        }
Exemplo n.º 11
0
        public void AtualizarTipo(string idTipo, TipoDTO tipoNew)
        {
            if ((idTipo != null) && (tipoNew != null))
            {
                Tipo tipoNovo = new Tipo {
                    IdTipo        = idTipo,
                    DescricaoTipo = tipoNew.DescricaoTipo.ToUpper()
                };

                _context.CollectionTipo.ReplaceOne(tipo => tipo.IdTipo == idTipo, tipoNovo);
            }

            this.Mensagem = "Falha ao executar o metodo AtualizarTipo() DAO";
        }
Exemplo n.º 12
0
        public TipoDTO Consultar(TipoDTO tipoDTO)
        {
            var resultado = new Tipo();

            if (string.IsNullOrEmpty(tipoDTO.Nome))
            {
                resultado = DataContext.Tipos.AsNoTracking().FirstOrDefault(tipo => tipo.Codigo == tipoDTO.Codigo);
            }
            else
            {
                resultado = DataContext.Tipos.AsNoTracking().FirstOrDefault(tipo => tipo.Nome.ToLower() == tipoDTO.Nome.ToLower());
            }

            return(Conversor.Mapear(resultado));
        }
Exemplo n.º 13
0
        public IHttpActionResult Create(TipoDTO tipoDTO)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            var tipo = Mapper.Map <TipoDTO, Tipo>(tipoDTO);

            _UnityOfWork.Tipos.Add(tipo);
            _UnityOfWork.SaveChanges();

            tipoDTO.TipoId = tipo.TipoId;

            return(Created(new Uri(Request.RequestUri + "/" + tipo.TipoId), tipoDTO));
        }
Exemplo n.º 14
0
        public TipoDTO ObterTipoPorId(string idTipo)
        {
            if (idTipo != null)
            {
                var resultado = _context.CollectionTipo.Find <Tipo>(tipo => tipo.IdTipo == idTipo).FirstOrDefault();

                TipoDTO tipoDTO = new TipoDTO {
                    IdTipo        = resultado.IdTipo,
                    DescricaoTipo = resultado.DescricaoTipo
                };
                return(tipoDTO);
            }

            this.Mensagem = "Falha ao executar o metodo ObterTipoPorId() DAO";

            return(null);
        }
Exemplo n.º 15
0
        public List <TipoDTO> ObterTodosTipos()
        {
            List <TipoDTO> tipos = new List <TipoDTO>();

            var sort = Builders <Tipo> .Sort.Ascending(tipo => tipo.DescricaoTipo);

            var Tipoes = _context.CollectionTipo.Find(tipo => true).Sort(sort).ToList();

            foreach (var item in Tipoes)
            {
                TipoDTO v = new TipoDTO {
                    IdTipo        = item.IdTipo,
                    DescricaoTipo = item.DescricaoTipo
                };
                tipos.Add(v);
            }
            return(tipos);
        }
Exemplo n.º 16
0
        public List <TipoDTO> ObterPorFiltro(TipoDTO dto)
        {
            List <TipoDTO> lista;

            try
            {
                ComandText = "stp_GER_TIPO_OBTERPORFILTRO";

                AddParameter("DESCRICAO", dto.Descricao);
                AddParameter("@SIGLA", dto.Sigla);

                MySqlDataReader dr = ExecuteReader();

                lista = new List <TipoDTO>();

                while (dr.Read())
                {
                    dto = new TipoDTO();

                    dto.Codigo    = int.Parse(dr[0].ToString());
                    dto.Descricao = dr[1].ToString();
                    dto.Sigla     = dr[2].ToString();
                    dto.Estado    = int.Parse(dr[3].ToString());
                    dto.Operacao  = dr[4].ToString();
                    lista.Add(dto);
                }
            }
            catch (Exception ex)
            {
                dto              = new TipoDTO();
                dto.Sucesso      = false;
                dto.MensagemErro = ex.Message.Replace("'", "");
                lista            = new List <TipoDTO>();
                lista.Add(dto);
            }
            finally
            {
                FecharConexao();
            }

            return(lista);
        }
Exemplo n.º 17
0
        public IHttpActionResult Update(int id, TipoDTO tipoDTO)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            var tipoInPersistence = _UnityOfWork.Tipos.Get(id);

            if (tipoInPersistence == null)
            {
                return(NotFound());
            }

            Mapper.Map <TipoDTO, Tipo>(tipoDTO, tipoInPersistence);

            _UnityOfWork.SaveChanges();

            return(Ok(tipoDTO));
        }
Exemplo n.º 18
0
        public TipoDTO Eliminar(TipoDTO dto)
        {
            try
            {
                ComandText = "stp_GER_TIPO_EXCLUIR";

                AddParameter("CODIGO", dto.Codigo);

                dto.Codigo  = ExecuteNonQuery();
                dto.Sucesso = true;
            }
            catch (Exception ex)
            {
                dto.Sucesso      = false;
                dto.MensagemErro = ex.Message.Replace("'", "");
            }
            finally
            {
                FecharConexao();
            }

            return(dto);
        }
Exemplo n.º 19
0
        public TipoDTO Adicionar(TipoDTO dto)
        {
            try
            {
                ComandText = "stp_GER_TIPO_ADICIONAR";
                AddParameter("DESCRICAO", dto.Descricao);
                AddParameter("SIGLA", dto.Sigla);
                AddParameter("SITUACAO", dto.Estado);
                AddParameter("@UTILIZADOR", dto.Utilizador);
                dto.Codigo  = ExecuteInsert();
                dto.Sucesso = true;
            }
            catch (Exception ex)
            {
                dto.Sucesso      = false;
                dto.MensagemErro = ex.Message.Replace("'", "");
            }
            finally
            {
                FecharConexao();
            }

            return(dto);
        }
Exemplo n.º 20
0
 public List <TipoDTO> ObterPorFiltro(TipoDTO dto)
 {
     return(dao.ObterPorFiltro(dto));
 }
Exemplo n.º 21
0
 public TipoDTO ObterPorPK(TipoDTO dto)
 {
     return(dao.ObterPorPK(dto));
 }
Exemplo n.º 22
0
 public async Task <string> Cadastrar(TipoDTO tipo)
 {
     return(_Requisicao.ExecutarRequisicao <TipoDTO, string>(tipo, _BLL.Cadastrar).Result);
 }
Exemplo n.º 23
0
 public void Apagar(TipoDTO dto)
 {
     dao.Eliminar(dto);
 }
Exemplo n.º 24
0
 public async Task <string> Cadastrar(TipoDTO tipoDTO)
 {
     TipoDAL.Cadastrar(tipoDTO);
     return("Idioma " + tipoDTO.Nome + " Cadastrado com Sucesso!");
 }