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