public HttpResponseMessage PostFlight([FromBody] FLIGHT flight) { try { using (TECAirlinesDBEntities entities = new TECAirlinesDBEntities()) { entities.INSERT_FLIGHT(flight.FLIGHT_ID, flight.PLANE_ID, flight.ORIGIN_AIRPORT, flight.DESTINATION_AIRPORT, flight.FSTATUS); entities.SaveChanges(); var message = Request.CreateResponse(HttpStatusCode.Created, flight); message.Headers.Location = new Uri(Request.RequestUri + flight.FLIGHT_ID.ToString()); return(message); } } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex)); } }