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