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