Exemplo n.º 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,
                              CommentContext commentContext)
        {
            loggerFactory.AddConsole();

            loggerFactory.AddDebug();

            //loggerFactory.AddProvider(new NLog.Extensions.Logging.NLogLoggerProvider());
            loggerFactory.AddNLog();

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

            else
            {
                app.UseExceptionHandler();
            }

            commentContext.EnsureSeedDataForContext();

            app.UseStatusCodePages();
            AutoMapper.Mapper.Initialize(cfg =>
            {
                cfg.CreateMap <Entities.Comment, Models.CommentWithoutRepliesDto>();
                cfg.CreateMap <Entities.Comment, Models.CommentDto>();
                cfg.CreateMap <Entities.Reply, Models.ReplyDto>();
                cfg.CreateMap <Models.ReplyForCreationDto, Entities.Reply>();
                cfg.CreateMap <Models.ReplyForUpdateDto, Entities.Reply>();
                cfg.CreateMap <Entities.Reply, Models.ReplyForUpdateDto>();
            });

            app.UseMvc();
        }
Exemplo n.º 2
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, CommentContext commentContext)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.UseRouting();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapGet("/", async context =>
                {
                    await context.Response.WriteAsync("Hello World!");
                });
            });

            commentContext.EnsureSeedDataForContext();
            app.UseMvc();
        }