public IHttpActionResult Patch([FromODataUri] int key, Delta <ReasonForTransfer> patch) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } ReasonForTransfer reasonfortransfer = db.ReasonForTransfers.Find(key); if (reasonfortransfer == null) { return(NotFound()); } patch.Patch(reasonfortransfer); try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!ReasonForTransferExists(key)) { return(NotFound()); } else { throw; } } return(Updated(reasonfortransfer)); }
// PUT odata/ReasonsForTransfer(5) public IHttpActionResult Put([FromODataUri] int key, ReasonForTransfer reasonfortransfer) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (key != reasonfortransfer.Id) { return(BadRequest()); } db.Entry(reasonfortransfer).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!ReasonForTransferExists(key)) { return(NotFound()); } else { throw; } } return(Updated(reasonfortransfer)); }
// POST odata/ReasonsForTransfer public IHttpActionResult Post(ReasonForTransfer reasonfortransfer) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.ReasonForTransfers.Add(reasonfortransfer); db.SaveChanges(); return(Created(reasonfortransfer)); }
// DELETE odata/ReasonsForTransfer(5) public IHttpActionResult Delete([FromODataUri] int key) { ReasonForTransfer reasonfortransfer = db.ReasonForTransfers.Find(key); if (reasonfortransfer == null) { return(NotFound()); } db.ReasonForTransfers.Remove(reasonfortransfer); db.SaveChanges(); return(StatusCode(HttpStatusCode.NoContent)); }