public UserService(BlogInfoContext context) { _context = context; }
public BlogInfoRepository(BlogInfoContext context) { _context = context; }
// 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, BlogInfoContext blogInfoContext) { loggerFactory.AddNLog(); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler(); } AutoMapper.Mapper.Initialize(cfg => { cfg.CreateMap <Entities.BlogPost, Models.BlogPostDto>(); cfg.CreateMap <Models.BlogPostDto, Entities.BlogPost>(); cfg.CreateMap <Models.BlogPostForCreationDto, Entities.BlogPost>().ConstructUsing(x => new BlogPost(x.Title, x.Contents)); cfg.CreateMap <Models.BlogPostForUpdateDto, Entities.BlogPost>(); cfg.CreateMap <Entities.User, Models.UserDto>(); cfg.CreateMap <Models.UserDto, Entities.User>(); cfg.CreateMap <Models.UserForCreationDto, Entities.User>(); }); app.UseMvc(); //app.UseIISPlatformHandler(); //app.UseStatusCodePages(); // global cors policy app.UseCors(x => x .AllowAnyOrigin() .AllowAnyMethod() .AllowAnyHeader() .AllowCredentials()); app.UseAuthentication(); //REDIRECT api call app.Use(async(context, next) => { await next(); if (context.Response.StatusCode == 404 && !Path.HasExtension(context.Request.Path.Value)) { context.Response.Redirect("/"); return; } }); app.UseDefaultFiles(); app.UseStaticFiles(); //app.Use(async (context, next) => // { // await next(); // if(context.Response.StatusCode==404 && !Path.HasExtension(context.Request.Path.Value) && !context.Request.Path.Value.StartsWith("/api/")) // { // context.Request.Path = "/index.html"; // await next(); // } // }); }