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, CarContext shoppingCartContext)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler(appBuilder =>
                {
                    appBuilder.Run(async context =>
                    {
                        context.Response.StatusCode = 500;
                        await context.Response.WriteAsync("An unexpected fault happened. Try again later.");
                    });
                });
            }



            shoppingCartContext.EnsureSeedDataForContext();
#pragma warning disable CS0618 // Type or member is obsolete
            AutoMapper.Mapper.Initialize(cfg =>
            {
                cfg.CreateMap <Car, CarDto>();
                cfg.CreateMap <CarForCreationDto, Car>();
                cfg.CreateMap <CarForUpdateDto, Car>();
                cfg.CreateMap <Car, CarForUpdateDto>();
            });

            app.UseCors("MyPolicy");
#pragma warning restore CS0618 // Type or member is obsolete
            app.UseMvc();
        }