// POST: odata/mdBays public async Task <IHttpActionResult> Post(mdBay mdBay) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.mdBays.Add(mdBay); await db.SaveChangesAsync(); return(Created(mdBay)); }
// DELETE: odata/mdBays(5) public async Task <IHttpActionResult> Delete([FromODataUri] int key) { mdBay mdBay = await db.mdBays.FindAsync(key); if (mdBay == null) { return(NotFound()); } db.mdBays.Remove(mdBay); await db.SaveChangesAsync(); return(StatusCode(HttpStatusCode.NoContent)); }
// PUT: odata/mdBays(5) public async Task <IHttpActionResult> Put([FromODataUri] int key, Delta <mdBay> patch) { Validate(patch.GetEntity()); if (!ModelState.IsValid) { return(BadRequest(ModelState)); } mdBay mdBay = await db.mdBays.FindAsync(key); if (mdBay == null) { return(NotFound()); } patch.Put(mdBay); try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!mdBayExists(key)) { return(NotFound()); } else { throw; } } return(Updated(mdBay)); }