Example #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, IGameServerService gameServerService, IStadiumService stadiumService, UserManager <AppUser> _userManager, RoleManager <AppRole> _roleManager)
        {
            DBDefaultDataInitiliazer.SeedData(gameServerService, stadiumService, _userManager, _roleManager);


            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/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();
            }
            app.UseHttpsRedirection();
            app.UseStaticFiles();


            app.UseRouting();
            app.UseAuthentication();
            app.UseAuthorization();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllerRoute(
                    name: "Area",
                    pattern: "{area:exists}/{controller=Home}/{action=Index}/{id?}");

                endpoints.MapControllerRoute(
                    name: "default",
                    pattern: "{controller=Home}/{action=Index}/{id?}");
            });
        }
 public TournamentController(IStadiumService stadiumService, IGameServerService gameServerService, ITournamentService tournamentService, IMapper mapper, ITeamService teamService, ITournamentTeamsService tournamentTeamsService)
 {
     _stadiumService         = stadiumService;
     _gameServerService      = gameServerService;
     _tournamentService      = tournamentService;
     _teamService            = teamService;
     _mapper                 = mapper;
     _tournamentTeamsService = tournamentTeamsService;
 }
Example #3
0
 protected GameServerModuleBase(IGameServerService gameServerService, ILogger <ModuleBase> logger)
 {
     this.gameServerService = gameServerService;
     this.logger            = logger;
 }
        public static void SeedData(IGameServerService _gameServerService, IStadiumService _stadiumService, UserManager <AppUser> _userManager, RoleManager <AppRole> _roleManager)
        {
            var gameServers = _gameServerService.GetAll();

            if (gameServers.Count <= 0)
            {
                _gameServerService.Add(new GameServerEntity {
                    ServerName = "EU Dedicated"
                });
                _gameServerService.Add(new GameServerEntity {
                    ServerName = "USA Dedicated"
                });
                _gameServerService.Add(new GameServerEntity {
                    ServerName = "Hosted Server"
                });
            }

            var stadiums = _stadiumService.GetAll();

            if (stadiums.Count <= 0)
            {
                _stadiumService.Add(new StadiumEntity {
                    Name = "Real Football"
                });
                _stadiumService.Add(new StadiumEntity {
                    Name = "Good"
                });
                _stadiumService.Add(new StadiumEntity {
                    Name = "Classic"
                });
                _stadiumService.Add(new StadiumEntity {
                    Name = "Small"
                });
                _stadiumService.Add(new StadiumEntity {
                    Name = "Real Football"
                });
                _stadiumService.Add(new StadiumEntity {
                    Name = "Small Pong"
                });
            }


            var roles = _roleManager.Roles.ToList();

            if (roles.Count <= 0)
            {
                _roleManager.CreateAsync(new AppRole {
                    Name = ConstRoles.Admin
                }).Wait();
                _roleManager.CreateAsync(new AppRole {
                    Name = ConstRoles.Member
                }).Wait();
            }


            var adminUser = _userManager.FindByNameAsync("compo").Result;

            if (adminUser == null)
            {
                AppUser user = new AppUser
                {
                    Email    = "*****@*****.**",
                    Login    = "******",
                    UserName = "******"
                };
                string pass = "******";
                _userManager.CreateAsync(user, pass).Wait();
                _userManager.AddToRoleAsync(user, ConstRoles.Admin).Wait();
            }
        }