// 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(); app.UseBrowserLink(); using (var serviceScope = app.ApplicationServices.GetRequiredService <IServiceScopeFactory>() .CreateScope()) { StoreDataInitializer.InitializeData(serviceScope.ServiceProvider.GetRequiredService <StoreContext>()); } } else { app.UseExceptionHandler("/Products/Error"); } app.UseStaticFiles(); app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller=Products}/{action=Index}/{id?}"); }); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) { loggerFactory.AddConsole(Configuration.GetSection("Logging")); loggerFactory.AddDebug(); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); //app.UseBrowserLink(); using (var serviceScope = app.ApplicationServices.GetRequiredService <IServiceScopeFactory>() .CreateScope()) { StoreDataInitializer.InitializeData(app.ApplicationServices); } } else { app.UseExceptionHandler("/Products/Error"); } app.UseStaticFiles(); app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller=Products}/{action=Index}/{id?}"); }); }
public OrderTests() { var storeContextFactory = new StoreContextFactory(); StoreDataInitializer.InitializeData(storeContextFactory.CreateDbContext(new string[0])); _db = storeContextFactory.CreateDbContext(new string[0]); }
public OrderRepoTests() { _repo = new OrderRepo(new OrderDetailRepo()); StoreDataInitializer.ClearData(_repo.Context); StoreDataInitializer.InitializeData(_repo.Context); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) { if (env.IsDevelopment()) { loggerFactory.AddConsole(Configuration.GetSection("Logging")); loggerFactory.AddDebug(); } if (env.IsDevelopment()) { using (var serviceScope = app.ApplicationServices.GetRequiredService <IServiceScopeFactory>().CreateScope()) { StoreDataInitializer.InitializeData(app.ApplicationServices); } } app.UseCors("AllowAll"); // has to go before UseMvc app.UseMvc(); }
static void Main(string[] args) { var _repo = new ShoppingCartRepo(new ProductRepo()); //StoreDataInitializer.ClearData(_repo.Context); StoreDataInitializer.InitializeData(_repo.Context); Console.ReadLine(); }
public OrderTests() : base() { using (StoreContext storeContext = new StoreContext()) { StoreDataInitializer.ClearData(storeContext); StoreDataInitializer.InitializeData(storeContext); } }
// 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 (var serviceScope = app .ApplicationServices .GetRequiredService <IServiceScopeFactory>() .CreateScope()) { StoreDataInitializer.InitializeData(serviceScope.ServiceProvider); } } app.UseCors("AllowAll"); app.UseMvc(); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) { // _env = env; if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); loggerFactory .AddConsole(Configuration.GetSection("Logging")) .AddDebug(); StoreDataInitializer.InitializeData(app.ApplicationServices); } app.UseCors("AllowAll"); app.UseMvc(); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { //services.AddMvc(); services .AddMvcCore(config => config.Filters.Add(new SpyStoreExceptionFilter(HostingEnvironment.IsDevelopment()))) .AddJsonFormatters(j => { j.ContractResolver = new DefaultContractResolver(); j.Formatting = Formatting.Indented; }) ; services.AddCors(options => { options.AddPolicy("AllowAll", builder => { builder.AllowAnyHeader().AllowAnyMethod().AllowAnyOrigin().AllowCredentials(); }); }); string connectionString = Configuration.GetConnectionString("SpyStore"); services.AddDbContext <StoreContext>( options => options.UseSqlServer(connectionString)); services.AddScoped <ICategoryRepo, CategoryRepo>(); services.AddScoped <IProductRepo, ProductRepo>(); services.AddScoped <ICustomerRepo, CustomerRepo>(); services.AddScoped <IShoppingCartRepo, ShoppingCartRepo>(); services.AddScoped <IOrderRepo, OrderRepo>(); services.AddScoped <IOrderDetailRepo, OrderDetailRepo>(); // Build the intermediate service provider var serviceProvider = services.BuildServiceProvider(); StoreDataInitializer.InitializeData(serviceProvider); }
public ProductRepoTests() { _repo = new ProductRepo(); StoreDataInitializer.ClearData(_repo.Context); StoreDataInitializer.InitializeData(_repo.Context); }
public ShoppingCartRepoTests() { _repo = new ShoppingCartRepo(new ProductRepo()); StoreDataInitializer.ClearData(_repo.Context); StoreDataInitializer.InitializeData(_repo.Context); }
public OrderTests() { _db = new StoreContext(); StoreDataInitializer.InitializeData(_db); }
public override void Dispose() { StoreDataInitializer.InitializeData(new StoreContext()); }
public ShoppingCartControllerNoUpdateTests() { RootAddress = "api/shoppingcart"; StoreDataInitializer.InitializeData(new StoreContext()); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env) { app.UseWebOptimizer(); app.UseWebSockets(); app.Use(async(context, next) => { if (context.Request.Path == "/ws") { if (context.WebSockets.IsWebSocketRequest) { WebSocket webSocket = await context.WebSockets.AcceptWebSocketAsync(); await Echo(context, webSocket); } else { context.Response.StatusCode = 400; } } else { await next(); } }); app.UseFileServer(); if (env.IsDevelopment()) { app.UseBrowserLink(); app.UseDeveloperExceptionPage(); app.UseDatabaseErrorPage(); using (var serviceScope = app.ApplicationServices.GetRequiredService <IServiceScopeFactory>() .CreateScope()) { var context = serviceScope.ServiceProvider.GetRequiredService <ApplicationDbContext>(); StoreDataInitializer.InitializeData(context); } } else { app.UseExceptionHandler("/Home/Error"); app.UseHsts(); } app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseCookiePolicy(); app.UseAuthentication(); //URL Rewrite Middleware //using (StreamReader apacheModRewriteStreamReader = File.OpenText("ApacheModRewrite.txt")) //using (StreamReader iisUrlRewriteStreamReader = File.OpenText("IISUrlRewrite.xml")) //{ var rwOptions = new RewriteOptions() .AddRedirect("foo", "Products/Featured", 302) //status is optional, defaults to 302 .AddRedirect("(Products/)([^FfPp0-9].*)", "$1Featured") .AddRewrite("bar", "Products/Featured", skipRemainingRules: true) .Add(RedirectXmlRequests); //.AddRedirectToHttps(302, 63812) //Force SSL //.AddApacheModRewrite(apacheModRewriteStreamReader) //.AddIISUrlRewrite(iisUrlRewriteStreamReader); app.UseRewriter(rwOptions); //} //app.UseMvcWithDefaultRoute(); app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller=Home}/{action=Index}/{id?}"); }); }