// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, SeedGames seedGames, SeedUsers seedUsers) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler(builder => { builder.Run(async context => { context.Response.StatusCode = (int)HttpStatusCode.InternalServerError; var error = context.Features.Get <IExceptionHandlerFeature>(); if (error != null) { context.Response.AddApplicationError(error.Error.Message); await context.Response.WriteAsync(error.Error.Message); } }); }); //app.UseHsts(); } //app.UseHttpsRedirection(); seedGames.SeedBoardGames(); //seedUsers.SeedBoardologyUsers(); app.UseCors(x => x.AllowAnyOrigin().AllowAnyMethod().AllowAnyHeader()); app.UseAuthentication(); app.UseMvc(); }
public static void Main(string[] args) { var host = CreateHostBuilder(args).Build(); using (var scope = host.Services.CreateScope()) { var services = scope.ServiceProvider; try { SeedGames.Initialize(services); } catch (Exception ex) { var logger = services.GetRequiredService <ILogger <Program> >(); logger.LogError(ex, "An error occurred seeding the DB."); } try { SeedArticle.Initialize(services); } catch (Exception ex) { var logger = services.GetRequiredService <ILogger <Program> >(); logger.LogError(ex, "An error occurred seeding the DB."); } } host.Run(); }
public static void Main(string[] args) { var host = BuildWebHost(args); using (var scope = host.Services.CreateScope()) { var services = scope.ServiceProvider; try { SeedPublishers.InitialPublisher(services); SeedGames.InitialGames(services); SeedStores.InitialStores(services); SeedUsers.InitialUsers(services); SeedOrders.InitialOrders(services); SeedOrdersItems.InitialOrderItems(services); } catch (Exception ex) { var logger = services.GetRequiredService <ILogger <Program> >(); logger.LogError(ex, "An error ocurred while seeding Games"); } } host.Run(); }
public static async Task Initialize(GoDbContext context, UserManager <GoUser> userManager, RoleManager <ApplicationRole> roleManager, IServiceProvider serviceProvider) { context.Database.EnsureCreated(); await SeedUsers.Seed(serviceProvider, context, userManager, roleManager); await SeedCourses.Seed(serviceProvider, context); await SeedCoursesUsers.Seed(serviceProvider, context); await SeedDestinations.Seed(serviceProvider, context); await SeedDestinationsUsers.Seed(serviceProvider, context); await SeedComments.Seed(serviceProvider, context); await SeedStories.Seed(serviceProvider, context); await SeedGames.Seed(serviceProvider, context); await SeedLevelGameParticipants.Seed(serviceProvider, context); }