public static async Task SeedAsync(AspnetRunContext aspnetrunContext, ILoggerFactory loggerFactory, int?retry = 0) { int retryForAvailability = retry.Value; try { // TODO: Only run this if using a real database aspnetrunContext.Database.Migrate(); aspnetrunContext.Database.EnsureCreated(); if (!aspnetrunContext.Categories.Any()) { aspnetrunContext.Categories.AddRange(GetPreconfiguredCategories()); await aspnetrunContext.SaveChangesAsync(); } if (!aspnetrunContext.Products.Any()) { aspnetrunContext.Products.AddRange(GetPreconfiguredProducts()); await aspnetrunContext.SaveChangesAsync(); } } catch (Exception exception) { if (retryForAvailability < 10) { retryForAvailability++; var log = loggerFactory.CreateLogger <AspnetRunContextSeed>(); log.LogError(exception.Message); await SeedAsync(aspnetrunContext, loggerFactory, retryForAvailability); } throw; } }
public ProductTests(ITestOutputHelper output) { _output = output; var dbOptions = new DbContextOptionsBuilder <AspnetRunContext>() .UseInMemoryDatabase(databaseName: "AspnetRun") .Options; _aspnetRunContext = new AspnetRunContext(dbOptions); _productRepository = new ProductRepository(_aspnetRunContext); }
public ProductRepository(AspnetRunContext dbContext) { _dbContext = dbContext ?? throw new ArgumentNullException(nameof(dbContext)); }
public ProductRepository(AspnetRunContext dbContext) : base(dbContext) { }
public CategoryRepository(AspnetRunContext dbContext) : base(dbContext) { }
public CompareRepository(AspnetRunContext dbContext) : base(dbContext) { }
public TransactionBehaviour(AspnetRunContext dbContext, ILogger <TransactionBehaviour <TRequest, TResponse> > logger) { _dbContext = dbContext ?? throw new ArgumentException(nameof(AspnetRunContext)); _logger = logger ?? throw new ArgumentException(nameof(ILogger)); }
public Repository(AspnetRunContext context) : base(context) { }
public RepositoryBase(AspnetRunContext context) { _context = context; }
public IssueRepository(AspnetRunContext dbContext) : base(dbContext) { }
public OrderRepository(AspnetRunContext dbContext) : base(dbContext) { }
public WishlistRepository(AspnetRunContext dbContext) : base(dbContext) { }