public async Task CleanUpFlightsAdded()
        {
            // get all flights in the db
            var flights = await _context.Flights.ToListAsync();

            // walk through and remove them
            foreach (Flight flight in flights)
            {
                _context.Remove(flight);
                _context.Entry(flight).State = EntityState.Deleted;
            }

            // save the changes in the db
            await _context.SaveChangesAsync();

            // get all pilots in the db
            var pilots = await _context.Pilots.ToListAsync();

            // walk through and remove them
            foreach (Pilot pilot in pilots)
            {
                _context.Remove(pilot);
                _context.Entry(pilot).State = EntityState.Deleted;
            }
            // save the changes in the db
            await _context.SaveChangesAsync();
        }
示例#2
0
        public async Task CleanUp()
        {
            // get all routes in the db
            List <RoutePoint> routePoints = await _context.RoutePoints.ToListAsync();

            _context.Remove(route1);
            _context.Remove(route2);

            // walk through and remove them
            for (int i = 0; i < routePoints.Count; i++)
            {
                RoutePoint rp = routePoints[i];
                _ = _context.Remove(rp);
                _context.Entry(rp).State = EntityState.Deleted;
            }
            var queryPoints = await _context.Points.ToListAsync();

            for (int i = 0; i < queryPoints.Count; i++)
            {
                Point p = queryPoints[i];
                _ = _context.Remove(p);
                _context.Entry(p).State = EntityState.Deleted;
            }
            // tell the db all the routes were removed
            await _context.SaveChangesAsync();
        }
        public async Task CleanUpPilotsAdded()
        {
            // get all pilots in the db
            var pilots = await _context.Pilots.ToListAsync();

            // walk through and remove them
            foreach (Pilot pilot in pilots)
            {
                _context.Remove(pilot);
                _context.Entry(pilot).State = EntityState.Deleted;
            }
            // tell the db all the pilots were removed
            await _context.SaveChangesAsync();
        }
        public async Task CleanUp()
        {
            // get all routes in the db
            List <Route> routes = await _context.Routes.ToListAsync();

            // walk through and remove them
            for (int i = 0; i < routes.Count; i++)
            {
                Route route = routes[i];
                if (route.RouteId == "VR-140") // delete all routes except vr-140
                {
                    continue;
                }
                _ = _context.Remove(route);
                _context.Entry(route).State = EntityState.Deleted;
            }
            // tell the db all the routes were removed
            await _context.SaveChangesAsync();
        }