コード例 #1
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                using (IServiceScope scope = app.ApplicationServices.CreateScope())
                {
                    WebShopAppContext ctx = scope.ServiceProvider.GetService <WebShopAppContext>();
                    DBInitializer.SeedDB(ctx);
                }
            }
            else
            {
                using (var scope = app.ApplicationServices.CreateScope())
                {
                    var ctx = scope.ServiceProvider.GetService <WebShopAppContext>();
                    ctx.Database.EnsureCreated();
                }
                app.UseHsts();
            }
            //app.UseCors("AllowSpecificOrigin");
            app.UseCors("AllowAnyOrigin");

            app.UseHttpsRedirection();
            app.UseMvc();
        }
コード例 #2
0
 public ProductRepository(WebShopAppContext ctx)
 {
     _ctx = ctx;
 }
コード例 #3
0
 public OrderRepository(WebShopAppContext ctx)
 {
     _ctx = ctx;
 }