public async Task<IHttpActionResult> PostShipData(ShipData shipData) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.ShipDatas.Add(shipData); try { await db.SaveChangesAsync(); } catch (DbUpdateException) { if (ShipDataExists(shipData.Id)) { return Conflict(); } else { throw; } } return CreatedAtRoute("DefaultApi", new { id = shipData.Id }, shipData); }
public async Task<IHttpActionResult> PutShipData(Int64 id, ShipData shipData) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != shipData.Id) { return BadRequest(); } db.Entry(shipData).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ShipDataExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }