Beispiel #1
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, PaymentDbContext dbContext, UserManager <IdentityUser> userManager)
        {
            app.UseStaticFiles();
            app.UseSwagger();
            app.UseHsts();


            app.UseSwaggerUI(c =>
            {
                c.SwaggerEndpoint("/swagger/v1/swagger.json", "Payment.API v1");
                c.RoutePrefix = string.Empty;
                c.InjectStylesheet("/swagger-ui/Custom.css");
                c.InjectJavascript("/swagger-ui/Custom.js");
                c.DefaultModelRendering(ModelRendering.Example);
                c.DisplayRequestDuration();
                c.ShowExtensions();
                c.EnableFilter();
            });

            StartupDbInitializer.SeedData(dbContext, userManager);

            app.UseHttpsRedirection();

            app.UseRouting();

            app.UseAuthentication();

            app.UseAuthorization();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
            });
        }
Beispiel #2
0
        public static void Main(string[] args)
        {
            var host = CreateWebHostBuilder(args).Build();

            using (var scope = host.Services.CreateScope())
            {
                var services    = scope.ServiceProvider;
                var userManager = services.GetRequiredService <UserManager <ApplicationUser> >();
                try
                {
                    StartupDbInitializer.SeedData(services, userManager);
                }
                catch (Exception e)
                {
                    var logger = services.GetRequiredService <ILogger <Program> >();
                    logger.LogError(e, "An error has occurred seeding the database.");
                }
            };
            host.Run();
        }
Beispiel #3
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, UserManager <ApplicationUser> userManager, IServiceProvider service)
        {
            //if (env.IsDevelopment())
            //{
            //    app.UseDeveloperExceptionPage();
            //}

            app.UseHttpsRedirection();
            app.UseStaticFiles();
            app.UseCookiePolicy();

            app.UseAuthentication();
            StartupDbInitializer.SeedData(service, userManager);

            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}");
            });
        }
Beispiel #4
0
        public static void Main(string[] args)
        {
            var host = BuildWebHost(args);

            using (var scope = host.Services.CreateScope())
            {
                var services    = scope.ServiceProvider;
                var userManager = services.GetRequiredService <UserManager <ApplicationUser> >();
                try
                {
                    StartupDbInitializer.SeedData(services, userManager);
                    var context = services.GetRequiredService <RobotoDbContext>();
                    context.Database.Migrate();
                    SeedData.Initialize(services);
                }
                catch (Exception ex)
                {
                    var logger = services.GetRequiredService <ILogger <Program> >();
                    logger.LogError(ex, "An error occurred seeding the DB. Sad face.");
                }
            }
            host.Run();
        }