// 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, FlightInfoContext flightInfoContext) { loggerFactory.AddConsole(); loggerFactory.AddDebug(); loggerFactory.AddNLog(); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } // to seed data to db flightInfoContext.EnsureSeedDataForContext(); //to enable status codes from API to have appropriate http status code app.UseStatusCodePages(); //define mapping between db Entities and model DTO classes returned from API AutoMapper.Mapper.Initialize(cgf => { cgf.CreateMap <Flight, FlightDto>(); cgf.CreateMap <Passenger, PassengerDto>(); cgf.CreateMap <FlightBooking, SearchBookingDto>(); cgf.CreateMap <FlightBooking, BookingDto>(); cgf.CreateMap <FlightBooking, MakeBookingDto> (); cgf.CreateMap <PassengerDto, Passenger>(); cgf.CreateMap <FlightDto, Flight>(); cgf.CreateMap <MakeBookingDto, FlightBooking>(); }); // to enable MVC pattern app.UseMvc(); //app.Run(async (context) => //{ // await context.Response.WriteAsync("Hello World!"); //}); }
public FlightInfoesController(FlightInfoContext context) { _context = context; }