public void Configure(IApplicationBuilder app, IHostingEnvironment env, ApplicationSeed applicationSeed, ILoggerFactory loggerFactory) { loggerFactory.AddLog4Net(); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseHsts(); } app.ExceptionHandler(); app.UseAuthentication(); app.UseHttpsRedirection(); app.UseCors(options => { options.WithOrigins("http://localhost:4200", "https://juniorstartng.herokuapp.com").AllowAnyHeader().AllowAnyMethod().AllowCredentials(); }); app.UseSignalR(routes => { routes.MapHub <ChatHub>("/chat"); }); app.UseMvc(); app.EnableSwagger(); app.UseMiddleware <JwtTokenSlidingExpirationMiddleware>(); ApplicationSeed.SeedAsync(app.ApplicationServices).Wait(); }
public static void Seed(WebAppContext context) { var db = context.Database.EnsureCreated(); if (context.User.Any()) { return; } ApplicationSeed.CreateApplication(context); RoleSeed.CreateRole(context); UserSeed.CreateUser(context); }
static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); ISqlDataAccess sql = new SqlDataAccess(); IMainView mainView = new MainForm(); IPersonData personData = new PersonData(sql); IComboBoxData boxData = new ComboBoxData(sql); ApplicationSeed.Seed(boxData, sql); var mainPresenter = new MainPresenter(mainView, personData, boxData); mainPresenter.ShowView(); }
private void CreateDatabase(IApplicationBuilder app, IHostEnvironment env) { using (var serviceScope = app.ApplicationServices.GetService <IServiceScopeFactory>().CreateScope()) { try { var context = serviceScope.ServiceProvider.GetRequiredService <TodoContext>(); if (env.IsDevelopment()) { context.Database.EnsureDeleted(); Console.WriteLine($"Database successfully deleted."); } context.Database.Migrate(); Console.WriteLine($"Database successfully migrated."); ApplicationSeed.InitializeApplication(context, Configuration); } catch (Exception exception) { Console.WriteLine(exception.InnerException.Message); } } }
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ApplicationSeed applicationSeed) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseHsts(); } app.ExceptionHandler(); app.UseAuthentication(); app.UseHttpsRedirection(); app.UseCors("CorsPolicy"); app.UseMvc(); app.EnableSwagger(); app.UseMiddleware <JwtTokenExpirationMiddleware>(); ApplicationSeed.SeedAsync(app.ApplicationServices).Wait(); }
public static void Main(string[] args) { var host = CreateHostBuilder(args).Build(); using (var scope = host.Services.CreateScope()) { var serviceProvider = scope.ServiceProvider; try { var db = serviceProvider.GetRequiredService <ApplicationDbContext>(); var userManager = serviceProvider. GetRequiredService <UserManager <Registrar> >(); ApplicationSeed.Seed (userManager, db, false); } catch { } } host.Run(); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env, UserManager <Registrar> userManager, ApplicationDbContext db) { app.UseResponseCompression(); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); app.UseMigrationsEndPoint(); app.UseWebAssemblyDebugging(); } else { app.UseExceptionHandler("/Error"); // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. app.UseHsts(); } app.UseHttpsRedirection(); app.UseBlazorFrameworkFiles(); app.UseStaticFiles(); app.UseRouting(); app.UseIdentityServer(); app.UseAuthentication(); app.UseAuthorization(); ApplicationSeed.Seed(userManager, db, false); app.UseEndpoints(endpoints => { endpoints.MapRazorPages(); endpoints.MapControllers(); endpoints.MapHub <VisitorHub>("/visitorhub"); endpoints.MapFallbackToFile("index.html"); }); }