public async Task <ActionResult <FlightPlan> > GetFlightPlan(string id) { try { var plan = await manager.GetFlightPlan(id); // If we didn't find the plan we return Not Found if (plan == null) { return(NotFound("Didn't find the flight selected")); } // Returns the plan return(Ok(plan)); } // If exceptions has been thrown due to ussie with http connection - // returns bad request. catch (HttpRequestException) { return(BadRequest("Problem with http request to other servers")); } // Timeout - the servers connected to this server didn't bring the id fast enough. catch (Exception e) { return(BadRequest(e.Message)); } }
public IActionResult GetFlightPlan(string id) { FlightPlan flightPlan = _flightsManager.GetFlightPlan(id); if (flightPlan == FlightPlan.NULL) { return(BadRequest(new Error("Flight plan does not exist."))); } return(new OkObjectResult(JsonConvert.SerializeObject(flightPlan, Formatting.Indented))); }
public async Task <ActionResult> GetFlightPlan(string id) { try { // trying to get the flight plan from the inner server FlightPlan flightPlan = myFlightsManager.GetFlightPlan(id); // if the flight plan was not found if (flightPlan == null) { // trying to get the flight plan from the servers return(await TryGetFlightPlanFromServers(id)); } else { return(Ok(flightPlan)); } } catch { return(BadRequest("Failed receiving flight plan")); } }