public IHttpActionResult PutCabecalhoOrdemDeCompras(int id, CabecalhoOrdemDeCompras cabecalhoOrdemDeCompras) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != cabecalhoOrdemDeCompras.PedidoDaCompraID) { return(BadRequest()); } cabecalhoOrdemDeCompras.DataModificacao = DateTime.Now; db.Entry(cabecalhoOrdemDeCompras).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!CabecalhoOrdemDeComprasExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult GetCabecalhoOrdemDeCompras(int id) { CabecalhoOrdemDeCompras cabecalhoOrdemDeCompras = db.CabecalhoOrdemDeCompras.Find(id); if (cabecalhoOrdemDeCompras == null) { return(NotFound()); } return(Ok(cabecalhoOrdemDeCompras)); }
public IHttpActionResult PostCabecalhoOrdemDeCompras(CabecalhoOrdemDeCompras cabecalhoOrdemDeCompras) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } cabecalhoOrdemDeCompras.DataModificacao = DateTime.Now; db.CabecalhoOrdemDeCompras.Add(cabecalhoOrdemDeCompras); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = cabecalhoOrdemDeCompras.PedidoDaCompraID }, cabecalhoOrdemDeCompras)); }
public IHttpActionResult DeleteCabecalhoOrdemDeCompras(int id) { CabecalhoOrdemDeCompras cabecalhoOrdemDeCompras = db.CabecalhoOrdemDeCompras.Find(id); if (cabecalhoOrdemDeCompras == null) { return(NotFound()); } db.CabecalhoOrdemDeCompras.Remove(cabecalhoOrdemDeCompras); db.SaveChanges(); return(Ok(cabecalhoOrdemDeCompras)); }