// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, CardsAgainstHumanityAPIContext context)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.UseHttpsRedirection();
            app.UseStaticFiles();
            app.UseCookiePolicy();

            //2.2 Cors
            app.UseCors("MyAllowOrigins");

            //vσσr de endpoints!
            app.UseAuthentication();
            app.UseAuthorization();

            //2.3 Swagger
            app.UseSwagger(); //enable swagger
            app.UseSwaggerUI(c =>
            {
                // c.RoutePrefix = "swagger"; //path naar de UI pagina: /swagger/index.html
                c.SwaggerEndpoint("/swagger/v1/swagger.json", "CardsAgainstHumanity_API v1");
            });

            app.UseRouting();
            app.UseEndpoints(endpoints =>
            {
                endpoints.MapHub <LobbyHub>("/lobbyhub");
                endpoints.MapHub <GameHub>("/gamehub");
            });


            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
            });

            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller}/{action=Index}/{id?}");
            });

            //SEEDER met controler over reeds bestaande data
            //context via property dependancy
            ModelBuilderExtensions._configuration   = Configuration;
            ModelBuilderExtensions._context         = context;
            ModelBuilderExtensions._contentRootPath = env.ContentRootPath.Replace("CardsAgainstHumanity.API", "CardsAgainstHumanity.Models");

            ModelBuilderExtensions.SeedFromFile(); //Pas hier Hostenv beschikbaar (na Context building)
        }
Example #2
0
        //Door GenericRepo te erven worden de CRUD methodes beschikbaar
        //Repo heeft enkel als required format de context nodig.
        //Deze context ophalen via erven van de base

        public DeckRepo(CardsAgainstHumanityAPIContext context) : base(context)
        {
        }
 //ctor dependancy van de applicatie context:
 public GenericRepo(CardsAgainstHumanityAPIContext context)
 {
     this._context = context;
 }
 public DecksController(IDeckRepo _deckRepo, IMapper _mapper, CardsAgainstHumanityAPIContext context)
 {
     _context      = context;
     this.deckRepo = _deckRepo;
     this.mapper   = _mapper;
 }