Exemplo n.º 1
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env,
                              MyDbContextSeedData seeder)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseHsts();
            }

            app.UseHttpsRedirection();


            app.UseStaticFiles();
            app.UseAuthentication();
            //  app.UseAuthorization();

            app.UseMvc(config =>
            {
                config.MapRoute(
                    name: "MyFirstRoute",
                    template: "{controller}/{action}/{id?}",
                    defaults: new { controller = "App", action = "Index" }
                    );
            });

            seeder.EnsureSeedData().Wait();
        }
Exemplo n.º 2
0
    public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
    {
        if (env.IsDevelopment())
        {
            app.UseDeveloperExceptionPage();
        }

        app.UseFileServer();
        app.UseAuthentication();
        app.UseMvc(routes => routes.MapRoute("default", "{controller=Stores}/{action=Index}/{id?}"));
        MyDbContextSeedData.Initialize(app.ApplicationServices, _config).Wait();
    }
Exemplo n.º 3
0
        protected override async void OnStartup(StartupEventArgs e)
        {
            await _host.StartAsync();

            await MyDbContextSeedData.Initialize(_host.Services, Config);

            var bookRepository = _host.Services.GetRequiredService <IBookRepository>();
            var threadStart    = new ThreadStart(async() => await CheckBooksForExpiration(bookRepository));
            var thread         = new Thread(threadStart);

            thread.Start();
            var window = _host.Services.GetRequiredService <MainWindow>();

            window.DataContext = _host.Services.GetRequiredService <MainViewModel>();
            window.Show();
            base.OnStartup(e);
        }