public async Task <IHttpActionResult> PostRotaryTable(RotaryTable rotaryTable) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.RotaryTables.Add(rotaryTable); try { await db.SaveChangesAsync(); } catch (DbUpdateException) { if (RotaryTableExists(rotaryTable.TypeID)) { return(Conflict()); } else { throw; } } return(CreatedAtRoute("DefaultApi", new { id = rotaryTable.TypeID }, rotaryTable)); }
public async Task <IHttpActionResult> PutRotaryTable(string id, RotaryTable rotaryTable) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != rotaryTable.TypeID) { return(BadRequest()); } db.Entry(rotaryTable).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!RotaryTableExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public async Task <IHttpActionResult> GetRotaryTable(string id) { RotaryTable rotaryTable = await db.RotaryTables.FindAsync(id); if (rotaryTable == null) { return(NotFound()); } return(Ok(rotaryTable)); }
public async Task <IHttpActionResult> DeleteRotaryTable(string id) { RotaryTable rotaryTable = await db.RotaryTables.FindAsync(id); if (rotaryTable == null) { return(NotFound()); } db.RotaryTables.Remove(rotaryTable); await db.SaveChangesAsync(); return(Ok(rotaryTable)); }