// 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, CoreContext DbContext, AdminServices adminServ) { app.UseCors("AllowAll"); app.UseCors("localHost3000"); app.UseCors("localHost19001"); loggerFactory.AddConsole(Configuration.GetSection("Logging")); loggerFactory.AddDebug(); app.Use(async(routecontext, next) => { await next(); if (routecontext.Response.StatusCode == 404 && !Path.HasExtension(routecontext.Request.Path.Value)) { routecontext.Request.Path = "/index.html"; await next(); } }); app.UseDefaultFiles(new DefaultFilesOptions { DefaultFileNames = new List <string> { "index.html" } }) .UseStaticFiles() .UseMvc(); DbInitialize.Initialize(DbContext, adminServ); }
// 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, ApplicationDbContext context) { loggerFactory.AddConsole(Configuration.GetSection("Logging")); loggerFactory.AddDebug(); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); app.UseDatabaseErrorPage(); app.UseBrowserLink(); } else { app.UseExceptionHandler("/Home/Error"); } app.UseStaticFiles(); app.UseIdentity(); // Add external authentication middleware below. To configure them please see https://go.microsoft.com/fwlink/?LinkID=532715 app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller=Home}/{action=Index}/{id?}"); }); DbInitialize.Initialize(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, ApplicationDbContext context) { if (env.IsDevelopment()) { app.UseBrowserLink(); app.UseDeveloperExceptionPage(); app.UseDatabaseErrorPage(); } else { app.UseExceptionHandler("/Home/Error"); } app.UseStaticFiles(); app.UseAuthentication(); app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller=Home}/{action=Index}/{id?}"); }); DbInitialize.Initialize(context); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); app.UseDatabaseErrorPage(); } else { app.UseExceptionHandler("/Home/Error"); // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. app.UseHsts(); } app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseRouting(); app.UseAuthentication(); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllerRoute( name: "default", pattern: "{controller=Home}/{action=Index}/{id?}"); endpoints.MapRazorPages(); }); DbInitialize.Initialize(app); }
public static void Main(string[] args) { var host = new WebHostBuilder() .UseKestrel() .UseUrls("http://*:5000") .UseContentRoot(Directory.GetCurrentDirectory()) .UseIISIntegration() .UseStartup <Startup>() .Build(); using (var scope = host.Services.CreateScope()) { var services = scope.ServiceProvider; try { var context = services.GetRequiredService <SensorContext>(); DbInitialize.Initialize(context); } catch (Exception ex) { var logger = services.GetRequiredService <ILogger <Program> >(); logger.LogError(ex, "An error occurred while seeding the database."); } } host.Run(); }
/// <summary> /// The main entry point of the application. /// </summary> /// <param name="args">Any command-line arguments passed to the application on launch.</param> public static void Main(string[] args) { var host = BuildWebHost(args); using (var scope = host.Services.CreateScope()) { var services = scope.ServiceProvider; try { // Seed the database Core.Data.DbInitialize.Initialize( services, services.GetRequiredService <ApplicationDbContext>()); // Add sample data DbInitialize.Initialize(services); } catch (Exception ex) { var logger = services.GetRequiredService <ILogger <Program> >(); logger.LogError(ex, "An error occurred while migrating the database."); } } host.Run(); }
// 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, ProductContext context) { loggerFactory.AddConsole(Configuration.GetSection("Logging")); loggerFactory.AddDebug(); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); app.UseBrowserLink(); } else { app.UseExceptionHandler("/Home/Error"); } app.UseStaticFiles(); app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller=Home}/{action=Index}/{id?}"); }); DbInitialize.Initialize(context); }
public Task Invoke(HttpContext httpContext, kindergartenContext db) { if (!(httpContext.Session.Keys.Contains("starting"))) { DbInitialize.Initialize(db); httpContext.Session.SetString("starting", "Yes"); } return(_next.Invoke(httpContext)); }
public TeamsController(MyProjectContext context) { _context = context; if (!_context.Team.Any() || !_context.Player.Any()) { DbInitialize.Initialize(_context); } }
public ConsumerDealServiceTests() { var options = new DbContextOptionsBuilder <DealLocator.API.Models.DealLocatorDbContext>() .UseInMemoryDatabase(databaseName: "LocationDatabase") .Options; var context = new DealLocatorDbContext(options); sut = new ConsumerDealService(context); DbInitialize.Initialize(context); }
private static void CreateDbIfNoExist(IHost host) { using var create = host.Services.CreateScope(); var serviceProv = create.ServiceProvider; var context = serviceProv.GetRequiredService <AuthContext>(); context.Database.EnsureCreated(); if (!context.Users.Any()) { DbInitialize.Initialize(context); } else { } }
private static void CreateDbIfNotExists(IHost host) { using (var scope = host.Services.CreateScope()) { var services = scope.ServiceProvider; try { var context = services.GetRequiredService <DataContext>(); DbInitialize.Initialize(context); } catch (Exception ex) { var logger = services.GetRequiredService <ILogger <Program> >(); logger.LogError(ex, "An error occurred creating the DB."); } } }
public static void Main(string[] args) { var host = BuildWebHost(args); using (var scope = host.Services.CreateScope()) { var services = scope.ServiceProvider; try { var context = services.GetRequiredService <Context>(); DbInitialize.Initialize(context); } catch (Exception ex) { var logger = services.GetRequiredService <ILogger <Program> >(); logger.LogError(ex, GeneralMessages.MSG0006); } } host.Run(); }
public static void Main(string[] args) { var host = CreateWebHostBuilder(args).Build(); using (var scope = host.Services.CreateScope()) { var services = scope.ServiceProvider; try { var context = services.GetRequiredService <UserModelContext>(); DbInitialize.Initialize(context); } catch (Exception ex) { var logger = services.GetRequiredService <ILogger <Program> >(); logger.LogError(ex, "An error occured while seeding the database"); } } host.Run(); }
public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IServiceProvider serviceProvider) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseHttpsRedirection(); app.UseRouting(); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); DbInitialize.Initialize(serviceProvider); }
public static void Main(string[] args) { var host = CreateWebHostBuilder(args).Build(); using (var serviceScope = host.Services.CreateScope()) { var services = serviceScope.ServiceProvider; try { var context = services.GetRequiredService <PostContext>(); DbInitialize.Initialize(context); } catch (Exception ex) { var logger = services.GetRequiredService <ILogger <Program> >(); logger.LogError(ex, ex.Message); throw; } } host.Run(); }
public static void Main(string[] args) { _host = CreateHostBuilder(args).Build(); using (var scope = _host.Services.CreateScope()) { var services = scope.ServiceProvider; try { DbInitialize.Initialize(services.GetService <AppDbContext>()); } catch (Exception e) { var log = services.GetService <ILogger <Program> >(); log.LogError(e, "Can't initialize DB."); } } _host.Run(); }
public static void Main(string[] args) { var builder = BuildWebHost(args); using (var scope = builder.Services.CreateScope()) { var services = scope.ServiceProvider; try { var context = services.GetRequiredService <FeatureContext>(); if (!context.Institutions.Any()) { DbInitialize.Initialize(context); } } catch (Exception ex) { var logger = services.GetRequiredService <ILogger <Program> >(); logger.LogError(ex, "An error occurred while seeding the database."); } } builder.Run(); }
public Task Invoke(HttpContext context, CustomsContext dbContext) { DbInitialize.Initialize(dbContext); return(_next.Invoke(context)); }
public Task Invoke(HttpContext _db, ForestryContext dbContext) { DbInitialize.Initialize(dbContext); return(_next.Invoke(_db)); }