예제 #1
0
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, WalletDbContext walletDbContext)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();

                var extenderDbConnectionString = Configuration.GetConnectionString(WalletDbContext.ConnectionStringName);
                if (!SqlServerDbUtil.DatabaseExists(extenderDbConnectionString))
                {
                    SqlServerDbUtil.CreateDatabase(extenderDbConnectionString, collation: "SQL_Latin1_General_CP1_CI_AI");

                    walletDbContext.Database.EnsureCreated();
                }
            }

            app.UseHttpsRedirection();

            app.UseCustomExceptionHandler();

            app.UseRouting();

            if (!env.IsProduction())
            {
                app.UseSwagger();
                app.UseSwaggerUI(o =>
                {
                    o.SwaggerEndpoint($"/swagger/{SwaggerApiDocumentationKey}/swagger.json", "Wallet API v1");
                    o.DocExpansion(DocExpansion.None);
                });
            }

            app.UseAuthorization();

            app.UseEndpoints(endpoints => { endpoints.MapControllers(); });
        }
예제 #2
0
        // 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();

                var soloDbContextConnectionStringName = _configuration.GetConnectionString(SoloDbContext.ConnectionStringName);
                if (!SqlServerDbUtil.DatabaseExists(soloDbContextConnectionStringName))
                {
                    SqlServerDbUtil.CreateDatabase(soloDbContextConnectionStringName, collation: "SQL_Latin1_General_CP1_CI_AI");

                    var dbInitializer = app.ApplicationServices.GetService <DevDatabaseInitializer>();
                    dbInitializer.Initialize();
                }
            }

            // todo: есть шанс что успею взяться за авторизацию
            // if (env.IsDevelopment() || env.EnvironmentName == "Demo")
            //     IdentityModelEventSource.ShowPII = true;

            // app.UseHttpsRedirection();

            app.UseRouting();

            app.UseCors();

            app.UseAuthentication();
            app.UseAuthorization();

            app.UseEndpoints(endpoints => { endpoints.MapControllers(); });
        }