Exemplo n.º 1
0
 public GamblerService(BetsKingDbContext dbContext, IHttpContextAccessor httpContextAccessor, IOptions <AuthSettings> authSettings)
 {
     _dbContext           = dbContext;
     _passwordHasher      = new PasswordHasher <Gambler>();
     _httpContextAccessor = httpContextAccessor;
     _authSettings        = authSettings.Value;
 }
Exemplo n.º 2
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, BetsKingDbContext dbContext)
        {
            app.UseAuthentication();
            app.UseResponseCompression();

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

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

            app.UseBlazor <Client.Program>();

            if (env.IsDevelopment())
            {
                InitDev(dbContext);
            }
            else
            {
                InitProd(dbContext);
            }
        }
Exemplo n.º 3
0
        private void InitData(BetsKingDbContext dbContext)
        {
            if (!dbContext.Roles.Any())
            {
                dbContext.Roles.Add(new Role
                {
                    Name = "Gambler"
                });

                dbContext.Roles.Add(new Role
                {
                    Name = "Admin"
                });

                dbContext.SaveChanges();
            }

            if (dbContext.Gamblers.FirstOrDefault(g => g.UserName.Equals(Configuration["DbInit:AdminUserName"], StringComparison.InvariantCultureIgnoreCase)) == null)
            {
                var admin = new Gambler
                {
                    UserName    = Configuration["DbInit:AdminUserName"],
                    DisplayName = Configuration["DbInit:AdminDisplayName"]
                };

                var passwordHasher = new PasswordHasher <Gambler>();

                admin.Password = passwordHasher.HashPassword(admin, Configuration["DbInit:AdminPassword"]);

                var entry = dbContext.Gamblers.Add(admin);

                dbContext.SaveChanges();

                dbContext.UserRoles.AddRange(new UserRole
                {
                    GamblerId = entry.Entity.Id,
                    RoleId    = 1
                },
                                             new UserRole
                {
                    GamblerId = entry.Entity.Id,
                    RoleId    = 2
                });

                dbContext.SaveChanges();
            }
        }
 public MatchBetService(BetsKingDbContext dbContext)
 {
     _dbContext = dbContext;
 }
Exemplo n.º 5
0
 public RoundService(BetsKingDbContext dbContext)
 {
     _dbContext = dbContext;
 }
Exemplo n.º 6
0
 public MatchService(BetsKingDbContext dbContext, IMatchBetService matchBetService)
 {
     _dbContext       = dbContext;
     _matchBetService = matchBetService;
 }
Exemplo n.º 7
0
 public void InitProd(BetsKingDbContext dbContext)
 {
     dbContext.Database.Migrate();
     InitData(dbContext);
 }
Exemplo n.º 8
0
 public void InitDev(BetsKingDbContext dbContext)
 {
     dbContext.Database.EnsureCreated();
     InitData(dbContext);
 }