private static void VulTabellen(WinkelDbContext winkelDbContext) { if (!winkelDbContext.Klanten.Any()) { winkelDbContext.Klanten.Add(new Klant { KlantIdentificatie = "KL123" }); } if (!winkelDbContext.Producten.Any()) { winkelDbContext.Producten.Add(new Product { ProductIdentificatie = "Appel", Prijs = 0.56m }); winkelDbContext.Producten.Add(new Product { ProductIdentificatie = "Peer", Prijs = 0.32m }); } winkelDbContext.SaveChanges(); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { // Data store registraties services.AddScoped(wdbctx => { var options = new DbContextOptionsBuilder <WinkelDbContext>() .UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=Winkel;Integrated Security=True") .Options; var winkelDbContext = new WinkelDbContext(options); winkelDbContext.Database.EnsureCreated(); VulTabellen(winkelDbContext); return(winkelDbContext); }); services.AddScoped <IKlantRepository, KlantRepository>(); services.AddScoped <IProductRepository, ProductRepository>(); services.AddScoped <IOrderRepository, OrderRepository>(); services.AddScoped <IUnitOfWork, UnitOfWork>(); // Application service registraties services.AddScoped <IOrderMetKortingUsecase, OrderMetKortingUsecase>(); services.AddScoped <IToonProductenUseCase, ToonProductenUsecase>(); services.AddControllers(); }
public OrderServiceTests() { var options = new DbContextOptionsBuilder <WinkelDbContext>() .UseInMemoryDatabase(databaseName: "Winkel") .Options; _winkelDbContext = new WinkelDbContext(options); _winkelDbContext.Database.EnsureDeleted(); }
public OrderStepDefinitions(ScenarioContext scenarioContext) { _scenarioContext = scenarioContext ?? throw new System.ArgumentNullException(nameof(scenarioContext)); var options = new DbContextOptionsBuilder <WinkelDbContext>() .UseInMemoryDatabase(databaseName: "Winkel") .Options; _winkelDbContext = new WinkelDbContext(options); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddScoped(wdbctx => { var options = new DbContextOptionsBuilder <WinkelDbContext>() .UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=Winkel;Integrated Security=True") .Options; var winkelDbContext = new WinkelDbContext(options); winkelDbContext.Database.EnsureCreated(); VulTabellen(winkelDbContext); return(winkelDbContext); }); services.AddScoped <ProductService>(); services.AddControllers(); }
public OrderRepository(WinkelDbContext winkelDbContext) { _winkelDbContext = winkelDbContext ?? throw new ArgumentNullException(nameof(winkelDbContext)); }
public OrderController(WinkelDbContext winkelDbContext) { _winkelDbContext = winkelDbContext ?? throw new System.ArgumentNullException(nameof(winkelDbContext)); }
public ProductService(WinkelDbContext winkelDbContext) { _winkelDbContext = winkelDbContext ?? throw new System.ArgumentNullException(nameof(winkelDbContext)); }