Beispiel #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, TrappistDbContext context, ConnectionString connectionString, IMemoryCache cache)
        {
            app.UseExceptionless(Configuration.GetSection("ExceptionlessKey").Value);

            loggerFactory.AddConsole(Configuration.GetSection("Logging"));
            loggerFactory.AddDebug();

            app.UseForwardedHeaders(new ForwardedHeadersOptions
            {
                ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto
            });

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseDatabaseErrorPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
            }

            app.UseStaticFiles();



            if (env.IsDevelopment())
            {
                app.UseStaticFiles(new StaticFileOptions
                {
                    FileProvider = new PhysicalFileProvider(Path.GetFullPath(Path.Combine(env.ContentRootPath, "node_modules"))),
                    RequestPath  = new PathString("/node_modules")
                });
            }

            if (/*env.IsDevelopment()*/ true)
            {
                app.UseMiniProfiler();
            }

            app.UseAuthentication();
            app.UseSignalR(mapHub =>
            {
                mapHub.MapHub <TrappistHub>("TrappistHub");
            });

            app.UseSession();

            // Add external authentication middleware below. To configure them please see http://go.microsoft.com/fwlink/?LinkID=532715
            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "pagenotfound",
                    template: "pagenotfound",
                    defaults: new { controller = "Home", action = "PageNotFound" });
                routes.MapRoute(
                    name: "conduct",
                    template: "conduct/{link?}/{route?}",
                    defaults: new { controller = "Home", action = "Conduct", route = "register" });
                routes.MapRoute(
                    name: "setup",
                    template: "setup",
                    defaults: new { controller = "Home", action = "Setup" });
                routes.MapRoute(
                    name: "login",
                    template: "login",
                    defaults: new { controller = "Account", action = "Login" });
                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}");
                routes.MapSpaFallbackRoute(
                    name: "spa-fallback",
                    defaults: new { controller = "Home", action = "Index" });
            });

            if (!string.IsNullOrEmpty(connectionString.Value))
            {
                context.Database.Migrate();
                context.Seed();
            }
            #region Auto Mapper Configuration
            Mapper.Initialize(cfg =>
            {
                cfg.CreateMap <CodeSnippetQuestionAC, CodeSnippetQuestion>()
                .ForMember(x => x.CodeSnippetQuestionTestCases, opts => opts.Ignore())
                .ReverseMap();
                cfg.CreateMap <SingleMultipleAnswerQuestionAC, SingleMultipleAnswerQuestion>().ForMember(x => x.SingleMultipleAnswerQuestionOption, opts => opts.Ignore()).ReverseMap();
                cfg.CreateMap <QuestionDetailAC, Question>().ReverseMap();
                cfg.CreateMap <QuestionAC, Question>().ReverseMap();
                cfg.CreateMap <Question, QuestionDetailAC>();
                cfg.CreateMap <SingleMultipleAnswerQuestion, SingleMultipleAnswerQuestionAC>();
                cfg.CreateMap <Category, CategoryAC>();
                cfg.CreateMap <CategoryAC, Category>();
                cfg.CreateMap <CodeSnippetQuestion, CodeSnippetQuestionAC>();
                cfg.CreateMap <Question, QuestionAC>();
                cfg.CreateMap <Test, TestAC>();
                cfg.CreateMap <TestAC, Test>();
                cfg.CreateMap <TestIpAddress, TestIpAddressAC>();
            });
            #endregion

            app.UseEFSecondLevelCache();
        }
Beispiel #2
0
 public void MigrateAndSeedDb()
 {
     _trappistDbContext.Database.Migrate();
     _trappistDbContext.Seed();
 }