Ejemplo n.º 1
0
        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));
            }
        }
Ejemplo n.º 2
0
        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)));
        }
Ejemplo n.º 3
0
 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"));
     }
 }