예제 #1
0
 public void AddSeedData()
 {
     if (SeedDataService != null)
     {
         SeedDataService.AddSeedData(MockView);
     }
 }
예제 #2
0
        public static void Main(string[] args)
        {
            var host = CreateHostBuilder(args).Build();

            using (var scope = host.Services.CreateScope())
            {
                var services = scope.ServiceProvider;

                try
                {
                    SeedDataService.Initialize(services);
                }
                catch (Exception)
                {
                    throw;
                }
            }

            host.Run();
        }
예제 #3
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public async void Configure(IApplicationBuilder app, SeedDataService seederService, ILoggerFactory loggerFactory)
        {
            //app.UseIISPlatformHandler();
            //app.UseDefaultFiles();
            loggerFactory.AddDebug((str, level) =>
            {
                return((level == LogLevel.Critical) || (level == LogLevel.Error));
            });

            app.UseStaticFiles();

            //Order Matters !!!
            app.UseIdentity();

            AutoMapper.Mapper.Initialize((config) =>
            {
                config.CreateMap <Trip, TripViewModel>().ReverseMap();
                config.CreateMap <Stop, StopViewModel>().ReverseMap();
            });
            app.UseMvc(config =>
            {
                var defaults = new { controller = "App", action = "Index" };
                config.MapRoute(
                    name: "Default",
                    template: "{controller}/{action}/{id?}",
                    defaults: new { controller = "App", action = "Index" });
            });


            //app.Run(async (context) =>
            //{
            //    await context.Response.WriteAsync($"Hello World!:{context.Request.Path}");
            //});

            await seederService.EnsureSeedDataAsync();
        }