public static async Task SeedAsync(CategoryContext catalogContext, int?retry = 0)
        {
            int retryForAvailability = retry.Value;

            try
            {
                if (!catalogContext.Categories.Any())
                {
                    catalogContext.Categories.AddRange(
                        GetPreconfiguredCatalogTypes());

                    await catalogContext.SaveChangesAsync();
                }

                if (!catalogContext.Products.Any())
                {
                    catalogContext.Products.AddRange(
                        GetPreconfiguredItems());

                    await catalogContext.SaveChangesAsync();
                }
            }
            catch (Exception ex)
            {
                if (retryForAvailability < 10)
                {
                    retryForAvailability++;

                    await SeedAsync(catalogContext, retryForAvailability);
                }
            }
        }
Beispiel #2
0
 public OrderRepository(CategoryContext dbContext) : base(dbContext)
 {
 }
Beispiel #3
0
 public FrameworkRepository(CategoryContext dbContext)
 {
     _dbContext = dbContext;
 }