public ActionResult AddNewFlightPlan(FlightPlan newFlightPlan) { // check if the flight plan is valid if (ModelState.IsValid) { // generate new id string flight_id = this.flightPlansModel.GenerateFlightId(newFlightPlan.CompanyName); // creating the flight object from the flight plan Flight newFlight = flightsModel.CreateFlightByFlightPlan(newFlightPlan, flight_id); newFlight.IsExternal = false; // adding the new flight to the list this.flightsModel.AddNewFlight(newFlight); // adding the flight plan this.flightPlansModel.AddNewFlightPlan(newFlightPlan, flight_id); return(CreatedAtAction(actionName: "AddNewFlightPlan", newFlight)); } else { return(BadRequest()); } }