public IHttpActionResult Post(TipoPagamento_POCO produto)
 {
     try
     {
         tipopagamento newCat = (tipopagamento)produto;
         contexto.tipopagamento.Add(newCat);
         contexto.SaveChanges();
         return(RedirectToRoute("DefaultApi", new { controller = "tipopagamento", id = newCat.tpa_cod }));
     }
     catch (Exception e)
     {
         return(BadRequest());
     }
 }
 public IHttpActionResult Delete(int id)
 {
     try
     {
         if (id == 0)
         {
             throw new Exception("ID INVÁLIDO");
         }
         else
         {
             tipopagamento cat = contexto.tipopagamento.SingleOrDefault(c => c.tpa_cod == id);
             contexto.tipopagamento.Remove(cat);
             contexto.SaveChanges();
             return(Ok());
         }
     }
     catch (Exception e)
     {
         return(NotFound());
     }
 }
        public IHttpActionResult Put(int id, TipoPagamento_POCO e)
        {
            try
            {
                tipopagamento cli = contexto.tipopagamento.SingleOrDefault(gen => gen.tpa_cod == id);
                if (id == 0 || cli == null)
                {
                    throw new Exception("ID inválido.");
                }
                else
                {
                    cli.tpa_nome = e.nome;

                    contexto.SaveChanges();
                    return(RedirectToRoute("DefaultApi", new { controller = "tipopagamento", id = id }));
                }
            }
            catch (Exception ex)
            {
                return(NotFound());
            }
        }