Exemplo n.º 1
0
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
        {
            loggerFactory.AddConsole(Configuration.GetSection("Logging"));
            loggerFactory.AddDebug();

            app.UseCors("CorsPolicy");

            app.UseFailingMiddleware();

            ConfigureAuth(app);

            app.UseMvcWithDefaultRoute();

            app.UseSwagger()
            .UseSwaggerUi();

            OrderingContextSeed.SeedAsync(app).Wait();

            var integrationEventLogContext = new IntegrationEventLogContext(
                new DbContextOptionsBuilder <IntegrationEventLogContext>()
                .UseSqlServer(Configuration["ConnectionString"], b => b.MigrationsAssembly("Ordering.API"))
                .Options);

            integrationEventLogContext.Database.Migrate();
        }
Exemplo n.º 2
0
 private async Task WaitForSqlAvailabilityAsync(ILoggerFactory loggerFactory, IApplicationBuilder app, int retries = 0)
 {
     var logger = loggerFactory.CreateLogger(nameof(Startup));
     var policy = CreatePolicy(retries, logger, nameof(WaitForSqlAvailabilityAsync));
     await policy.ExecuteAsync(async() =>
     {
         await OrderingContextSeed.SeedAsync(app);
     });
 }
Exemplo n.º 3
0
        private void InitializeDatabase(IApplicationBuilder app, IHostingEnvironment env)
        {
            using (var serviceScope = app.ApplicationServices.GetService <IServiceScopeFactory>().CreateScope())
            {
                var settings = serviceScope.ServiceProvider.GetRequiredService <IOptions <OrderingSettings> >();
                var logger   = serviceScope.ServiceProvider.GetRequiredService <ILogger <OrderingContextSeed> >();

                var context = serviceScope.ServiceProvider.GetRequiredService <OrderingContext>();

                OrderingContextSeed configurationDbContextSeed = new OrderingContextSeed();
                configurationDbContextSeed.SeedAsync(context, env, settings, logger).Wait();
            }
        }
Exemplo n.º 4
0
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
        {
            loggerFactory.AddConsole(Configuration.GetSection("Logging"));
            loggerFactory.AddDebug();

            app.UseCors("CorsPolicy");

            app.UseFailingMiddleware();

            ConfigureAuth(app);

            app.UseMvcWithDefaultRoute();

            app.UseSwagger()
            .UseSwaggerUi();

            OrderingContextSeed.SeedAsync(app).Wait();
        }