示例#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)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseWebAssemblyDebugging();
            }
            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();
            }

            using (FivePeaksDbContext context = new FivePeaksDbContext())
            {
                context.Database.EnsureCreated();

                //Add admins if new db

                List <AdminUser> baseUsers = context.Admins.ToList();

                if (baseUsers.All(u => u.Username != "James"))
                {
                    context.Admins.Add(new AdminUser {
                        Username = "******", Password = "******"
                    });
                    context.SaveChanges();
                }
                if (baseUsers.All(u => u.Username != "Stuart"))
                {
                    context.Admins.Add(new AdminUser {
                        Username = "******", Password = "******"
                    });
                    context.SaveChanges();
                }
            }

            app.UseHttpsRedirection();
            app.UseBlazorFrameworkFiles();
            app.UseStaticFiles();

            app.UseRouting();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapRazorPages();
                endpoints.MapControllers();
                endpoints.MapFallbackToPage("/BaseIndex");
            });
        }
示例#2
0
 public AccountsController(IWebHostEnvironment environment)
 {
     _environment = environment;
     _context     = new FivePeaksDbContext();
 }
示例#3
0
 public LeaderboardController(IWebHostEnvironment environment)
 {
     _environment = environment;
     _context     = new FivePeaksDbContext();
 }
示例#4
0
 public BaseIndexModel()
 {
     _context = new FivePeaksDbContext();
 }