public IHttpActionResult PostTable(int gridId, int tableNumber, int capacity, bool isSmokingAllowed, int xCoord, int yCoord, int xLength, int yLength) { //if (tableToAdd == null) { var table = new Table { //Id = id, Capacity = capacity, GridId = gridId, IsSmokingAllowed = isSmokingAllowed, TableNumber = tableNumber, xCoord = xCoord, yCoord = yCoord, xLength = xLength, yLength = yLength }; if (!ModelState.IsValid) { return BadRequest(ModelState); } db.Tables.Add(table); db.SaveChanges(); } return Ok(); }
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); }