예제 #1
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app,
                              ILoggerFactory loggerFactory,
                              IHostingEnvironment env,
                              WakeupContextSeedData seeder,
                              WakeupContext context)
        {
            Mapper.Initialize(config =>
            {
                config.CreateMap <MachineViewModel, Machine>().ReverseMap();
                config.CreateMap <UserViewModel, User>().ReverseMap();
            });

            if (env.IsDevelopment())
            {
                loggerFactory.AddDebug(LogLevel.Information);
                loggerFactory.AddConsole(LogLevel.Information);
                app.UseDeveloperExceptionPage();
            }
            else
            {
                loggerFactory.AddDebug(LogLevel.Error);
            }

            app.UseStaticFiles();

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

                //config.MapRoute(
                //    name: "ApiDefault",
                //    template: "api/v1/{controller}/{username}/{action}",
                //    defaults: new { action = "GetUser" }
                //);
            });

            context.Database.Migrate();
            seeder.EnsureSeedData().Wait();
        }
 public WakeupRepository(WakeupContext context)
 {
     _context = context;
 }