Beispiel #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, ApplicationDbContext ctx, IIdentitySeeder identitySeeder)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseStatusCodePages();
            }
            else
            {
                app.UseExceptionHandler("/error.html");
            }

            app.UseHttpsRedirection();
            app.UseStaticFiles();
            app.UseAuthentication();

            app.UseCookiePolicy();
            //app.UseMvcWithDefaultRoute();

            // Add custom route template

            app.UseStatusCodePagesWithReExecute("/errors/{0}");

            app.UseMvc(routes =>
            {
                // -> /bilar/1
                routes.MapRoute(
                    name: "bilar/vehicleId",
                    template: "bilar/{brandName}/{model}/{modelDescription}/{vehicleId:int}",
                    defaults: new { controller = "Home", action = "Vehicle" }
                    );

                // -> /bilar/nya och bilar/begagnade
                routes.MapRoute(
                    name: "bilar/state",
                    template: "bilar/{state}",
                    defaults: new { controller = "Home", action = "Index" }
                    );

                // -> /bilar
                routes.MapRoute(
                    name: "",
                    template: "bilar",
                    defaults: new { controller = "Home", action = "Index" }
                    );

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

            var runIdentitySeed = Task.Run(async() => await identitySeeder.CreateAdminAccountIfEmpty()).Result;

            VehicleSeed.FillIfEmpty(ctx);
        }
Beispiel #2
0
        static async Task Main(string[] args)
        {
            var bus = BusConfiguration.ConfigureMassTransit();
            await bus.StartAsync();

            Console.WriteLine("Press enter to seed customers");
            Console.ReadLine();

            await CustomerSeed.Publish(bus);

            Console.WriteLine("Press enter to seed vehicles");
            Console.ReadLine();

            await VehicleSeed.Publish(bus);

            Console.WriteLine("Press any key to exit...");
            Console.ReadKey();

            await bus.StopAsync();
        }
Beispiel #3
0
 static Task SeedVehicles() => VehicleSeed.ProtoSeed();