Пример #1
0
        public static async Task CheckForExistingBags()
        {
            var flights = new DummyData.DummyData().CreateFlights();

            foreach (var f in flights)
            {
                // check for bags
                var bags = await new FlightService().GetBagsForFlight(f.FlightNumber);

                // if no bags, add them
                if ((bags == null) || (bags.Count == 0))
                {
                    await InsertBags(f);
                }
            }
        }
Пример #2
0
        public static async Task InsertFlights()
        {
            var dummyFlights    = new DummyData.DummyData().CreateFlights();
            var existingFlights = CosmosDataService.Instance("FlightCollection").GetFlights();

            // Get current list of flights in DB.
            // If they match the dummy data, do nothing. If they don't create the dummy data.
            // This was done in case we want to let people create their own flights later.
            foreach (var f in dummyFlights)
            {
                // Check if dummy flight is already in DB
                var matches = existingFlights.Where(b => String.Equals(b.FlightNumber, f.FlightNumber)).ToList();

                // If not in DB, create it.
                if ((matches.Count == 0) || (matches == null))
                {
                    await CosmosDataService.Instance("FlightCollection").InsertItemAsync(f);
                }
                else
                {
                    return;
                }
            }
        }