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, 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();
            });
        }
Ejemplo n.º 2
0
 public SinginController(DAL.IDdService dbService)
 {
     _dbService = dbService;
 }
Ejemplo n.º 3
0
 public EnrollmentsController(DAL.IDdService dbService)
 {
     _dbService = dbService;
 }
Ejemplo n.º 4
0
 public StudentsController(DAL.IDdService dbService)
 {
     _dbService = dbService;
 }