public HttpResponseMessage PostAirplane([FromBody] AIRPLANE plane) { try { using (TECAirlinesDBEntities entities = new TECAirlinesDBEntities()) { entities.INSERT_AIRPLANE(plane.AIRPLANE_ID, plane.PILOT_ID); entities.SaveChanges(); var message = Request.CreateResponse(HttpStatusCode.Created, plane); message.Headers.Location = new Uri(Request.RequestUri + plane.AIRPLANE_ID.ToString()); return message; } } catch (Exception ex) { return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex); } }