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

            app.UseSwaggerUI(x =>
            {
                x.SwaggerEndpoint("/swagger/v1/swagger.json", "Foosball API");
            });

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            //app.UseHttpsRedirection();

            app.UseRouting();

            app.UseCors("MyPolicy");

            app.UseAuthentication();

            app.UseAuthorization();

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

            DBInitializer.Initialize(context);
        }
Example #2
0
 public UserController(IUserService userService, BoodschapContext context)
 {
     _context     = context;
     _userService = userService;
 }
Example #3
0
 public BoodschapController(BoodschapContext context)
 {
     _context = context;
 }
Example #4
0
        public static void Initialize(BoodschapContext context)
        {
            context.Database.EnsureCreated();
            // Look for any user.
            if (context.Users.Any())
            {
                return;   // DB has been seeded
            }

            byte[] saltAdmin = Hashing.getSalt();
            byte[] saltUser  = Hashing.getSalt();
            context.Users.AddRange(
                new User {
                FirstName = "admin", LastName = "admin", Email = "*****@*****.**", Password = Hashing.getHash("admin", saltAdmin), HashSalt = saltAdmin
            },
                new User {
                FirstName = "user1", LastName = "user1", Email = "*****@*****.**", Password = Hashing.getHash("user1", saltUser), HashSalt = saltUser
            }
                );
            context.SaveChanges();

            //context.Producten.AddRange(
            //    new Product { Naam = "Product 1", Prijs = 5.00, Omschrijving = "Testing product 1" },
            //    new Product { Naam = "Product 2", Prijs = 10.00, Omschrijving = "Testing product 2" },
            //    new Product { Naam = "Product 3", Prijs = 15.00, Omschrijving = "Testing product 3" });

            string json        = File.ReadAllText("Models/products.json");
            var    ProductList = JsonConvert.DeserializeObject <List <Product> >(json);

            context.Producten.AddRange(ProductList);
            context.SaveChanges();

            context.Boodschappen.AddRange(
                new Boodschap {
                UserID = 1, Status = "gepland"
            },
                new Boodschap {
                UserID = 1, Status = "uitgevoerd"
            }
                );
            context.SaveChanges();

            context.BoodschapRows.AddRange(
                new BoodschapRow {
                BoodschapID = 1, ProductID = 1, Aantal = 2
            },
                new BoodschapRow {
                BoodschapID = 1, ProductID = 2, Aantal = 5
            },
                new BoodschapRow {
                BoodschapID = 1, ProductID = 3, Aantal = 3
            },
                new BoodschapRow {
                BoodschapID = 2, ProductID = 4, Aantal = 8
            },
                new BoodschapRow {
                BoodschapID = 2, ProductID = 5, Aantal = 4
            }
                );
            context.SaveChanges();
        }
Example #5
0
 public UserService(IOptions <AppSettings> appSettings, BoodschapContext boodschapContext)
 {
     _appSettings      = appSettings.Value;
     _boodschapContext = boodschapContext;
 }
Example #6
0
 public ProductController(BoodschapContext context)
 {
     _context = context;
 }