public IHttpActionResult PostOrdenes(Models.Ordenes ordenes) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.Ordenes.Add(ordenes); try { db.SaveChanges(); } catch (DbUpdateException) { if (OrdenesExists(ordenes.ordenId)) { return(Conflict()); } else { throw; } } return(CreatedAtRoute("DefaultApi", new { id = ordenes.ordenId }, ordenes)); }
public IHttpActionResult PutOrdenes(int id, Models.Ordenes ordenes) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != ordenes.ordenId) { return(BadRequest()); } db.Entry(ordenes).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!OrdenesExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult GetOrdenes(int id) { Models.Ordenes ordenes = db.Ordenes.Find(id); if (ordenes == null) { return(NotFound()); } return(Ok(ordenes)); }
public IHttpActionResult DeleteOrdenes(int id) { Models.Ordenes ordenes = db.Ordenes.Find(id); if (ordenes == null) { return(NotFound()); } db.Ordenes.Remove(ordenes); db.SaveChanges(); return(Ok(ordenes)); }