Exemple #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,
                              BlogDbContext blogDbContext,
                              MediatorDbContext mediatorDbContext,
                              UserManager <UserEntity> userManager,
                              RoleManager <RoleEntity> roleManager)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseBrowserLink();
                app.UseDatabaseErrorPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
            }

            app.UseStaticFiles();

            app.UseAuthentication();

            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}");
            });

            blogDbContext.Database.Migrate();
            mediatorDbContext.Database.Migrate();

            //app.EnsureMediatorDbCreated();
            //app.EnsureBlogDbCreated();
            app.EnsureDefaultBlogCreated();
            app.EnsureDefaultUserCreated(userManager, roleManager);
            app.UseTheme();
        }
Exemple #2
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, IMediator mediator, MediatorDbContext mediatorDbContext)
        {
            // Ensure Weapsy.Mediator database is installed.
            mediatorDbContext.Database.Migrate();

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.Run(async(context) =>
            {
                // Create a sample product loading data from domain events.
                var product = await GettingStarted.CreateProduct(mediator);

                // Display product title.
                await context.Response.WriteAsync($"Product title: {product.Title}");
            });
        }