public IHttpActionResult PutTable(int id, Table table) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != table.Id) { return BadRequest(); } db.Entry(table).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!TableExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public IHttpActionResult PostTable(Table table) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.Table.Add(table); db.SaveChanges(); return CreatedAtRoute("DefaultApi", new { id = table.Id }, table); }