Beispiel #1
0
        private async Task SeedVehicleData()
        {
            await using (var _context = _serviceProvider.GetService <AppDbContext>())
            {
                await _context.Drones.AddAsync(new Drone(Guid.NewGuid(), "DroneX12"));

                var superCar = new Automobile(TestData.automobileId, TestData.automobileName);
                superCar.AddDriver(Guid.NewGuid(), "1st Capt.", true)
                .AddDriver(Guid.NewGuid(), "2nd Capt.", false);
                await _context.Automobiles.AddAsync(superCar);

                var planeX = new Plane(TestData.planeId, TestData.planeName);
                planeX.AddDriver(Guid.NewGuid(), "1st Capt.", true)
                .AddDriver(Guid.NewGuid(), "2nd Capt.", false)
                .AddDriver(Guid.NewGuid(), "3rd Capt.", false)
                .AddDriver(Guid.NewGuid(), "4th Capt.", false);
                await _context.Planes.AddAsync(planeX);

                var yactFx = new Yact(TestData.yactId, "YactFx");
                yactFx.AddDriver(Guid.NewGuid(), "1st Capt.", true)
                .AddDriver(Guid.NewGuid(), "2nd Capt.", false)
                .AddDriver(Guid.NewGuid(), "3rd Capt.", false);
                await _context.Yacts.AddAsync(yactFx);

                await _context.SaveChangesAsync();
            }
        }