public IHttpActionResult Put(int id, Venda_POCO e) { try { venda cli = contexto.venda.SingleOrDefault(gen => gen.ven_cod == id); if (id == 0 || cli == null) { throw new Exception("ID inválido."); } else { cli.ven_data = e.data; cli.ven_total = e.vlr_total; cli.ven_status = e.status; cli.cli_cod = e.id_cliente; cli.tpa_cod = e.id_tipopagamento; contexto.SaveChanges(); return(RedirectToRoute("DefaultApi", new { controller = "venda", id = id })); } } catch (Exception ex) { return(NotFound()); } }
public IHttpActionResult Post(Venda_POCO produto) { try { venda newCat = (venda)produto; contexto.venda.Add(newCat); contexto.SaveChanges(); return(RedirectToRoute("DefaultApi", new { controller = "venda", id = newCat.ven_cod })); } catch (Exception e) { return(BadRequest()); } }