// POST: odata/ChiTietHLs public IHttpActionResult Post(ChiTietHL chiTietHL) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.ChiTietHLs.Add(chiTietHL); db.SaveChanges(); return(Created(chiTietHL)); }
// DELETE: odata/ChiTietHLs(5) public IHttpActionResult Delete([FromODataUri] int key) { ChiTietHL chiTietHL = db.ChiTietHLs.Find(key); if (chiTietHL == null) { return(NotFound()); } db.ChiTietHLs.Remove(chiTietHL); db.SaveChanges(); return(StatusCode(HttpStatusCode.NoContent)); }
// PUT: odata/ChiTietHLs(5) public IHttpActionResult Put([FromODataUri] int key, Delta <ChiTietHL> patch) { Validate(patch.GetEntity()); if (!ModelState.IsValid) { return(BadRequest(ModelState)); } ChiTietHL chiTietHL = db.ChiTietHLs.Find(key); if (chiTietHL == null) { return(NotFound()); } patch.Put(chiTietHL); try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!ChiTietHLExists(key)) { return(NotFound()); } else { throw; } } return(Updated(chiTietHL)); }