protected WePrintController(IServiceProvider services) { Log = (ILogger)services.GetRequiredService(typeof(ILogger <>).MakeGenericType(GetType())); UserManager = services.GetRequiredService <UserManager <User> >(); Database = services.GetRequiredService <WePrintContext>(); Mapper = services.GetRequiredService <IMapper>(); Configuration = services.GetRequiredService <IConfiguration>(); CurrentUser = new AsyncLazy <User>(async() => await UserManager.GetUserAsync(HttpContext.User)); BlobContainerProvider = services.GetRequiredService <IBlobContainerProvider>(); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env, WePrintContext dbContext) { if (env.IsDevelopment() || env.IsStaging()) { app.UseDeveloperExceptionPage(); app.UseDatabaseErrorPage(); } else { app.UseExceptionHandler("/Error"); // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. app.UseHsts(); } app.GnuTerryPratchett(); app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseSpaStaticFiles(); app.UseRouting(); app.UseAuthentication(); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapAreaControllerRoute( "admin", "Admin", "Admin/{controller=Dashboard}/{action=Index}/{id?}"); endpoints.MapControllerRoute( "default", "{controller}/{action=Index}/{id?}"); endpoints.MapRazorPages(); }); app.UseSwagger(); // Enable middleware to serve swagger-ui (HTML, JS, CSS, etc.), // specifying the Swagger JSON endpoint. app.UseSwaggerUI(c => { c.SwaggerEndpoint("/swagger/v1/swagger.json", "My API V1"); }); app.UseSpa(spa => { spa.Options.SourcePath = "ClientApp"; if (env.IsDevelopment() || Environment.GetEnvironmentVariable("ASPNETCORE_RUN_NODE")?.ToUpper() == "TRUE") { spa.UseReactDevelopmentServer("start"); } }); }
public OrganizationsController(WePrintContext context, IAvatarProvider avatar, IServiceProvider services) : base(services) { _context = context; _avatar = avatar; }
protected ManagementController(IServiceProvider services) { Log = (ILogger)services.GetRequiredService(typeof(ILogger <>).MakeGenericType(GetType())); Database = services.GetRequiredService <WePrintContext>(); }