/*
         * Add the new flight with their server to data base,
         * And update is_external to true.
         */
        private async Task <int> UpdateAndAdd(List <Flight> flights, string url)
        {
            int validationError  = 0;
            var newFlights       = new List <FlightWithServer>();
            var flightFromServer = new List <Flight>(flights);

            if (flights == null)
            {
                return(0);
            }
            foreach (Flight flight in flightFromServer)
            {
                // Check if the flight is valid.
                if (!IsValidFlight(flight))
                {
                    // Invalid flight so we remove it, change flag so we will know that
                    // not all the flights were valid and continue to the next.
                    flights.Remove(flight);
                    validationError++;
                    continue;
                }
                // Valid flight- we add (if dont exist) it's id and serverURL to db,
                // and change is_external to true.
                flight.IsExternal = true;
                newFlights.Add(new FlightWithServer
                {
                    FlightId  = flight.FlightId,
                    ServerURL = url
                });
            }
            await database.AddFlightsFromServers(newFlights);

            return(validationError);
        }