public IHttpActionResult PostTransport(Transport transport) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.Transports.Add(transport); try { db.SaveChanges(); } catch (DbUpdateException) { if (TransportExists(transport.Id)) { return Conflict(); } else { throw; } } return CreatedAtRoute("DefaultApi", new { id = transport.Id }, transport); }
public IHttpActionResult PutTransport(Guid id, Transport transport) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != transport.Id) { return BadRequest(); } db.Entry(transport).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!TransportExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }