static void Main(string[] args)
        {
            var config = new ConfigurationBuilder()
                         .SetBasePath(Directory.GetCurrentDirectory())
                         .AddJsonFile("appsettings.json")
                         .AddCommandLine(args)
                         .Build();

            var optionsBuilder = new DbContextOptionsBuilder <TrashContext>()
                                 .UseSqlServer(config.GetConnectionString("TrashContext"));

            double timeFactor                = config.GetValue <double>("tf", 1.0F);
            string choosedFillStrategy       = config.GetValue <string>("fill", "simplerandom");
            IVolumeFillStrategy fillStrategy = new RandomFillVolume();

            // Add new strategies here
            if (choosedFillStrategy == "ontime")
            {
                fillStrategy = new OnTimeBasedFillVolume();
            }

            using (var context = new TrashContext(optionsBuilder.Options))
            {
                var faker = new DataFaker(context, fillStrategy);
                faker.TimeFactor = timeFactor;
                faker.Run();
            }
        }
Beispiel #2
0
 public DataFaker(TrashContext trashContext, IVolumeFillStrategy fillStrategy)
 {
     _trashContext               = trashContext ?? throw new ArgumentNullException(nameof(trashContext));
     _newVolumeGenerator         = fillStrategy ?? throw new ArgumentNullException(nameof(fillStrategy));
     _currentVirtualDateTime     = DateTime.Now;
     _cachedWasteCollectionAreas = new List <WasteCollectionArea>();
     TimeFactor = 1.0F;
 }
 public GarbageTrucksController(TrashContext context)
 {
     _context = context;
 }
Beispiel #4
0
 public WasteCollectionAreasController(TrashContext db)
 {
     _db = db;
 }
Beispiel #5
0
 public Seed(TrashContext context, UserManager <User> userManager, RoleManager <Role> roleManager)
 {
     _context     = context;
     _userManager = userManager;
     _roleManager = roleManager;
 }