Пример #1
0
        // 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)
        {
            loggerFactory.AddConsole(Configuration.GetSection("Logging"));
            loggerFactory.AddDebug();
            var options = new JwtBearerOptions
            {
                Audience  = "https://swcapi.threenine.co.uk",
                Authority = "https://swcapi.auth0.com/"
            };

            app.UseJwtBearerAuthentication(options);

            app.UseMvc();
            app.UseSwagger();
            app.UseSwaggerUI(c =>
            {
                c.SwaggerEndpoint("/swagger/v1/swagger.json", "SWC API V1");
            });

            using (var serviceScope = app.ApplicationServices.GetRequiredService <IServiceScopeFactory>().CreateScope())
            {
                if (!serviceScope.ServiceProvider.GetService <ApiContext>().AllMigrationsApplied())
                {
                    serviceScope.ServiceProvider.GetService <ApiContext>().Database.Migrate();
                    serviceScope.ServiceProvider.GetService <ApiContext>().EnsureSeeded();
                }
            }

            //Set up code for automapper configuration
            var seedTypes         = new Type[] { typeof(Api.Domain.Marker) };
            var assemblies        = Reflect.OnTypes.GetAssemblies(seedTypes);
            var typesInAssemblies = Reflect.OnTypes.GetAllExportedTypes(assemblies);

            MappingConfigurationFactory.LoadAllMappings(typesInAssemblies);
        }
Пример #2
0
        public RefererControllerTest()
        {
            //Set up code for automapper configuration
            var seedTypes         = new Type[] { typeof(Api.Domain.Marker) };
            var assemblies        = Reflect.OnTypes.GetAssemblies(seedTypes);
            var typesInAssemblies = Reflect.OnTypes.GetAllExportedTypes(assemblies);

            MappingConfigurationFactory.LoadAllMappings(typesInAssemblies);
        }