public static void DbInit(DwDbContext c) { c.Database.EnsureCreated(); //c.Database.Migrate(); c.CommonConfig.Add(new CommonConfigEntity { Item = "BlogPageSize", Value = "20" }); c.CommonConfig.Add(new CommonConfigEntity { Item = "BlogReplyPageSize", Value = "10" }); c.CommonConfig.Add(new CommonConfigEntity { Item = "ForumPostPageSize", Value = "20" }); c.CommonConfig.Add(new CommonConfigEntity { Item = "ForumReplyPageSize", Value = "20" }); c.CommonConfig.Add(new CommonConfigEntity { Item = "ForumSubReplyPageSize", Value = "10" }); c.SaveChanges(); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, DwDbContext dbc) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); app.UseSwagger(); app.UseSwaggerUI(c => { c.SwaggerEndpoint("/swagger/v1/swagger.json", "quizsite API"); }); } else { app.UseExceptionHandler("/Home/Error"); } app.UseStaticFiles(); //如/file对应的文件夹不存在,自动创建文件夹 if (!Directory.Exists(Configuration.GetSection("VirtualPath").GetValue <string>("File"))) { Directory.CreateDirectory(Configuration.GetSection("VirtualPath").GetValue <string>("File")); } app.UseFileServer(new FileServerOptions() { FileProvider = new PhysicalFileProvider(Configuration.GetSection("VirtualPath").GetValue <string>("File")), RequestPath = "/file", EnableDirectoryBrowsing = false }); Initialize.DbInit(dbc); app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller=Home}/{action=Index}/{id?}"); }); }
public static void DbInit(DwDbContext c) { c.Database.EnsureCreated(); //c.Database.Migrate(); c.SaveChanges(); }
public ViewBaseController(DwDbContext dbc, ILoggerFactory logFac, IServiceProvider svp) : base(dbc, logFac, svp) { }
public BlogController(DwDbContext dbc, ILoggerFactory logFac) : base(dbc, logFac) { _blogApi = new BlogApiController(dbc, logFac); }
//StackRedisHelper redis; public BlogApiController(DwDbContext dbc, ILoggerFactory logFac) : base(dbc, logFac) { //redis = StackRedisHelper.Instance; }
public ApiBaseController(DwDbContext dbc, ILoggerFactory logFac) : base(dbc, logFac) { }
public BaseController(DwDbContext dbc, ILoggerFactory logFac) { this.dbc = dbc; _log = logFac.CreateLogger("seekerhut"); }
// 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, DwDbContext c) { loggerFactory.AddConsole(Configuration.GetSection("Logging")); loggerFactory.AddDebug(); loggerFactory.AddNLog().AddDebug(); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); app.UseBrowserLink(); } else { app.UseExceptionHandler("/Home/Error"); } //app.UseSession(); app.UseWebSockets(); IConfigurationSection redisConf = Configuration.GetSection("Redis"); //StackRedisHelper.InitRedis(redisConf.GetValue<string>("ConnStr"), redisConf.GetValue<Int32>("Database"), redisConf.GetValue<string>("Name")); //如/file对应的文件夹不存在,自动创建文件夹 if (!Directory.Exists(Configuration.GetSection("VirtualPath").GetValue <string>("File"))) { Directory.CreateDirectory(Configuration.GetSection("VirtualPath").GetValue <string>("File")); } app.UseFileServer(new FileServerOptions() { FileProvider = new PhysicalFileProvider(Configuration.GetSection("VirtualPath").GetValue <string>("File")), RequestPath = "/file", EnableDirectoryBrowsing = false }); app.UseStaticFiles(); Initialize.DbInit(c); //app.UseErrorPage(); app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller=Home}/{action=Index}/{id?}"); }); }
public HomeApiController(DwDbContext dbc, ILoggerFactory logFac) : base(dbc, logFac) { }
public ErrorController(DwDbContext dbc, ILoggerFactory logFac) : base(dbc, logFac) { }
//protected StackRedisHelper redis; public BaseController(DwDbContext dbc, ILoggerFactory logFac, IServiceProvider svp) { this.dbc = dbc; _log = logFac.CreateLogger("simpleproj"); //redis = StackRedisHelper.Instance; }
public QuizController(DwDbContext dbc, ILoggerFactory logFac, IServiceProvider svp) : base(dbc, logFac, svp) { qac = new QuizApiController(dbc, logFac, svp); }