Ejemplo 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, PersonInfoContext personInfoContext)
        {
            //loggerFactory.AddConsole();
            //loggerFactory.AddDebug();
            // loggerFactory.AddProvider(new NLog.Extensions.Logging.NLogLoggerProvider());
            loggerFactory.AddNLog();

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

            personInfoContext.EnsureSeedDataForContext();

            AutoMapper.Mapper.Initialize(cfg =>
            {
                cfg.CreateMap <Person, PersonWithoutQuotesDto>();
                cfg.CreateMap <Person, PersonDto>();
                cfg.CreateMap <Quote, QuoteDto>();
                cfg.CreateMap <QuoteForCreationDto, Quote>();
                cfg.CreateMap <QuoteForUpdateDto, Quote>();
                cfg.CreateMap <Quote, QuoteForUpdateDto>();
            });

            app.UseMvc();
            app.UseStatusCodePages();
            app.Run(async(context) =>
            {
                await context.Response.WriteAsync("Hello World!");
            });
        }
Ejemplo n.º 2
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, PersonInfoContext personInfoContext)
        {
            loggerFactory.AddConsole();

            /* DB Context calls this method to seed the Master data in the related tables */
            personInfoContext.EnsureSeedDataForContext();

            /* For the Http Status code pages */
            app.UseStatusCodePages();

            AutoMapper.Mapper.Initialize(cfg =>
            {
                cfg.CreateMap <Entities.Person, Models.PersonDto>();
            });

            // Shows UseCors with CorsPolicyBuilder.
            app.UseCors(builder =>
            {
                builder.AllowAnyOrigin().AllowAnyMethod().AllowAnyHeader();
            });

            app.UseMvc();

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