// GET: api/Cadastro
        public IHttpActionResult Get()
        {
            RacoesResponse rResponse = new RacoesResponse();

            try
            {
                List <Racao> lista = Racao.Listar();
                rResponse.Racoes = new List <RacaoTO>();
                foreach (Racao r in lista)
                {
                    RacaoTO rTO = new RacaoTO();
                    rTO.Id   = r.Id;
                    rTO.Peso = r.Peso;
                    rTO.Nome = r.Nome;

                    rResponse.Racoes.Add(rTO);
                }
            }
            catch (Exception ex)
            {
                rResponse.Status   = -1;
                rResponse.Detalhes = ex.Message;
            }

            return(Ok(rResponse));
        }
        // PUT: api/Racao/5
        public IHttpActionResult Put(int id, [FromBody] RacaoTO racaoTO)
        {
            BaseResponse baseResponse = new BaseResponse();

            try
            {
                Racao.Atualizar(racaoTO.Id, racaoTO.Peso, racaoTO.Nome);
            }
            catch (NegocioException nex)
            {
                baseResponse.Status   = (int)nex.Codigo;
                baseResponse.Detalhes = nex.Message;
            }
            catch (Exception ex)
            {
                baseResponse.Status   = -1;
                baseResponse.Detalhes = ex.Message;
            }

            return(Ok(baseResponse));
        }
        public IHttpActionResult Remover([FromBody] RacaoTO racaoTO)
        {
            BaseResponse baseResponse = new BaseResponse();

            try
            {
                Racao.Remover(racaoTO.Id);
            }
            catch (NegocioException nex)
            {
                baseResponse.Status   = (int)nex.Codigo;
                baseResponse.Detalhes = nex.Message;
            }
            catch (Exception ex)
            {
                baseResponse.Status   = -1;
                baseResponse.Detalhes = ex.Message;
            }

            return(Ok(baseResponse));
        }
        // POST: api/Racao
        public IHttpActionResult Post([FromBody] RacaoTO racaoTO)
        {
            RacaoResponse rResponse = new RacaoResponse();

            rResponse.Racao.Peso = racaoTO.Peso;
            rResponse.Racao.Nome = racaoTO.Nome;

            try
            {
                rResponse.Racao.Id = Racao.Inserir(racaoTO.Peso, racaoTO.Nome);
            }
            catch (NegocioException nex)
            {
                rResponse.Status   = (int)nex.Codigo;
                rResponse.Detalhes = nex.Message;
            }
            catch (Exception ex)
            {
                rResponse.Status   = -1;
                rResponse.Detalhes = ex.Message;
            }

            return(Ok(rResponse));
        }