Example #1
0
        public static async Task <int> EnsureSeedData(this CoreDbDemoContext context)
        {
            var systemCount      = default(int);
            var retailerCount    = default(int);
            var brandCount       = default(int);
            var areaManagerCount = default(int);

            // Because each of the following seed method needs to do a save
            // (the data they're importing is relational), we need to call
            // SaveAsync within each method.
            // So let's keep tabs on the counts as they come back

            var dbSeeder = new DatabaseSeeder(context);

            if (!context.ExternalSystems.Any())
            {
                var pathToSeedData = Path.Combine(Directory.GetCurrentDirectory(), "SeedData", "SystemSeedData.json");
                systemCount = await dbSeeder.SeedSystemEntitiesFromJson(pathToSeedData);
            }
            if (!context.AreaManagers.Any())
            {
                var pathToSeedData = Path.Combine(Directory.GetCurrentDirectory(), "SeedData", "AreaManagerSeedData.json");
                areaManagerCount = await dbSeeder.SeedAreaManagerEntitiesFromJson(pathToSeedData);
            }
            if (!context.Brands.Any())
            {
                var pathToSeedData = Path.Combine(Directory.GetCurrentDirectory(), "SeedData", "BrandSeedData.json");
                brandCount = await dbSeeder.SeedBrandEntitiesFromJson(pathToSeedData);
            }
            if (!context.Retailers.Any())
            {
                var pathToSeedData = Path.Combine(Directory.GetCurrentDirectory(), "SeedData", "RetailerSeedData.json");
                retailerCount = await dbSeeder.SeedRetailerEntitiesFromJson(pathToSeedData);
            }

            return(brandCount + areaManagerCount + retailerCount + systemCount);
        }
Example #2
0
 public RequestRepository(CoreDbDemoContext context)
 {
     _context = context;
 }
Example #3
0
 public DatabaseSeeder(CoreDbDemoContext context)
 {
     _context = context;
 }
 public ExternalSystemRepository(CoreDbDemoContext context)
 {
     _context = context;
 }
 public RetailerRepository(CoreDbDemoContext context)
 {
     _context = context;
 }
 public StaffMemberRepository(CoreDbDemoContext context)
 {
     _context = context;
 }
 public AreaManagerRepository(CoreDbDemoContext contact)
 {
     _context = contact;
 }
Example #8
0
 public BrandRepository(CoreDbDemoContext context)
 {
     _context = context;
 }