public HttpResponseMessage PostPilot([FromBody] PILOT pilot) { try { using (TECAirlinesDBEntities entities = new TECAirlinesDBEntities()) { entities.INSERT_PILOT(pilot.PILOT_ID, pilot.PILOT_FNAME, pilot.PILOT_LNAME); entities.SaveChanges(); var message = Request.CreateResponse(HttpStatusCode.Created, pilot); message.Headers.Location = new Uri(Request.RequestUri + pilot.PILOT_ID.ToString()); return(message); } } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex)); } }