public void Configure(IApplicationBuilder app, IHostingEnvironment env, CentralLoggerContext db, UserService userService) { var defaultOptions = new DefaultFilesOptions(); defaultOptions.DefaultFileNames.Clear(); defaultOptions.DefaultFileNames.Add("index.html"); if (env.IsDevelopment()) { app .UseDeveloperExceptionPage() .UseDefaultFiles(defaultOptions) .UseStaticFiles() .UseSwagger() .UseSwaggerUI(c => { c.SwaggerEndpoint("/swagger/v1/swagger.json", "My API V1"); }); } else { app .UseHsts() .UseDefaultFiles(defaultOptions) .UseStaticFiles(); } app.UseCors(builder => builder.AllowAnyHeader().AllowAnyMethod().AllowAnyOrigin().AllowCredentials()); app.UseMvc(); app.UseSignalR(options => { options.MapHub <LogHub>("/LogHub"); }); GenrateDatabase(db, userService); }
private void GenrateDatabase(CentralLoggerContext db, UserService userService) { var createData = db.Database.EnsureCreated(); if (createData) { userService.AddUser("admin", "admin"); } }
private static void GenrateDatabase(CentralLoggerContext db, UserService userService) { Console.WriteLine("Create DB"); var createData = db.Database.EnsureCreated(); if (createData) { userService.AddUser("admin", "admin"); } userService.AddEmail("dotnet-script.dll"); Console.WriteLine("Create success"); }