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, ILoggerFactory loggerFactory, CityInfoContext cityInfoContext)
        {
            //loggerFactory.AddDebug();   //In >net Core 2.0 it is by default so no need
            //add NLog to ASP.NET Core
            //https://github.com/NLog/NLog.Web/wiki/Getting-started-with-ASP.NET-Core-2 followed this
            loggerFactory.AddNLog();

            //add NLog.Web
            app.AddNLogWeb();
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            //cityInfoContext.EnsureSeedDateForContext();
            app.UseMvc();
            app.UseStatusCodePages();
            cityInfoContext.EnsureSeedDateForContext();


            AutoMapper.Mapper.Initialize(cfg =>
            {
                cfg.CreateMap <Entities.City, Models.CityWithoutPointsofInterestsDto>();
                cfg.CreateMap <Entities.City, Models.CityDto>();
                cfg.CreateMap <Entities.PointofInterest, Models.PointofInterestDto>();
                cfg.CreateMap <Models.PointofInterestForCreationDto, Entities.PointofInterest>();
                cfg.CreateMap <Models.PointofInterestforUpdateDto, Entities.PointofInterest>();
                cfg.CreateMap <Entities.PointofInterest, Models.PointofInterestforUpdateDto>();
            });

            //app.Run(async (context) =>
            //{
            //    throw new Exception("EXAMPLE EXCEPTION");
            //});

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