// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env, DAL.IDdService dbService) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseMiddleware <Middleware.LoggingMiddleware>(); app.Use(async(context, next) => { if (!context.Request.Headers.ContainsKey("Index")) { context.Response.StatusCode = StatusCodes.Status401Unauthorized; await context.Response.WriteAsync("Nie podano indeksu"); return; } var indx = context.Request.Headers["Index"].ToString(); if (!dbService.CheckIndex(indx)) { context.Response.StatusCode = StatusCodes.Status401Unauthorized; await context.Response.WriteAsync("Nie ma takiego indeksu"); return; } await next(); }); app.UseRouting(); app.UseAuthentication(); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); }
public SinginController(DAL.IDdService dbService) { _dbService = dbService; }
public EnrollmentsController(DAL.IDdService dbService) { _dbService = dbService; }
public StudentsController(DAL.IDdService dbService) { _dbService = dbService; }