Example #1
0
        public async Task <ActionResult <FlightPlan> > CheckFlightPlanInServers(string id)
        {
            // We know that the flight isnt from our DB, and we got it from some where.
            // We have a DB that maps flights from out side servers, and the servers that we got them from.
            // We will search from which sever we got the flight from, according to the flight id.
            FlightByServerId serverUrl = await _context.FlightByServerIds.Where(x => x.FlightId == id).FirstAsync();

            if (serverUrl == null)
            {
                return(NotFound());
            }
            var flightPlan = await GetExternalFlightFromServer(serverUrl.ServerId, id);

            return(flightPlan);
        }
Example #2
0
 public async void AddAllExternalFlightToDb(List <Flight> allExternalFlight, string severUrl)
 {
     // Adding all the flights we got from a specific server and save it in the flight id to server Db.
     if (allExternalFlight == null)
     {
         return;
     }
     foreach (Flight flight in allExternalFlight)
     {
         FlightByServerId flightToDb = new FlightByServerId
         {
             ServerId = severUrl,
             FlightId = flight.FlightId,
         };
         _context.FlightByServerIds.Add(flightToDb);
         await _context.SaveChangesAsync();
     }
 }