protected void lbAddEmail_Click(object sender, EventArgs e)
        {
            EmailCounter += 1;

            EmailUserControl ctrl = (EmailUserControl)LoadControl("~/Controls/EmailUserControl.ascx");

            ctrl.ID = EmailCounter.ToString();
            otherEmailsDiv.Controls.Add(new LiteralControl("<br/>"));
            otherEmailsDiv.Controls.Add(ctrl);
            KolekcijaEmailova.Add(ctrl);
        }
Exemplo n.º 2
0
        protected override void Seed(cgMonoGameServer2015.Models.ApplicationDbContext context)
        {
            //  This method will be called after migrating to the latest version.

            //  You can use the DbSet<T>.AddOrUpdate() helper extension method
            //  to avoid creating duplicate seed data. E.g.
            //
            //    context.People.AddOrUpdate(
            //      p => p.FullName,
            //      new Person { FullName = "Andrew Peters" },
            //      new Person { FullName = "Brice Lambson" },
            //      new Person { FullName = "Rowan Miller" }
            //    );
            //

            context.Games.AddOrUpdate(g => g.GameName,
                                      new Game {
                GameName = "Battle Call"
            },
                                      new Game {
                GameName = "Pong"
            });

            context.SaveChanges();

            Random         r      = new Random();
            PasswordHasher hasher = new PasswordHasher();

            context.Users.AddOrUpdate(u => u.UserName,
                                      new ApplicationUser
            {
                XP             = r.Next(400),
                UserName       = "******",
                Email          = "*****@*****.**",
                EmailConfirmed = true,
                GamerTag       = "ppowell",
                PasswordHash   = hasher.HashPassword("itsPaul$1"),
                SecurityStamp  = Guid.NewGuid().ToString()
            },

                                      new ApplicationUser
            {
                XP             = r.Next(400),
                UserName       = "******" + Counter.ToString() + "@itsligo.ie",
                Email          = "User" + EmailCounter.ToString() + "@itsligo.ie",
                EmailConfirmed = true,
                GamerTag       = "GamerTag" + _usercounter.ToString(),
                PasswordHash   = hasher.HashPassword("Password$" + _usercounter.ToString()),
                SecurityStamp  = Guid.NewGuid().ToString()
            },
                                      new ApplicationUser
            {
                XP             = r.Next(400),
                UserName       = "******" + Counter.ToString() + "@itsligo.ie",
                Email          = "User" + EmailCounter.ToString() + "@itsligo.ie",
                EmailConfirmed = true,
                GamerTag       = "GamerTag" + _usercounter.ToString(),
                PasswordHash   = hasher.HashPassword("Password$" + _usercounter.ToString()),
                SecurityStamp  = Guid.NewGuid().ToString()
            },
                                      new ApplicationUser
            {
                XP             = r.Next(400),
                UserName       = "******" + Counter.ToString() + "@itsligo.ie",
                Email          = "User" + EmailCounter.ToString() + "@itsligo.ie",
                EmailConfirmed = true,
                GamerTag       = "GamerTag" + _usercounter.ToString(),
                PasswordHash   = hasher.HashPassword("Password$" + _usercounter.ToString()),
                SecurityStamp  = Guid.NewGuid().ToString()
            },
                                      new ApplicationUser
            {
                XP             = r.Next(400),
                UserName       = "******" + Counter.ToString() + "@itsligo.ie",
                Email          = "User" + EmailCounter.ToString() + "@itsligo.ie",
                EmailConfirmed = true,
                GamerTag       = "GamerTag" + _usercounter.ToString(),
                PasswordHash   = hasher.HashPassword("Password$" + _usercounter.ToString()),
                SecurityStamp  = Guid.NewGuid().ToString()
            },
                                      new ApplicationUser {
                XP             = r.Next(400),
                UserName       = "******" + Counter.ToString() + "@itsligo.ie",
                Email          = "User" + EmailCounter.ToString() + "@itsligo.ie",
                EmailConfirmed = true,
                GamerTag       = "GamerTag" + _usercounter.ToString(),
                PasswordHash   = hasher.HashPassword("Password$" + _usercounter.ToString()),
                SecurityStamp  = Guid.NewGuid().ToString()
            },
                                      new ApplicationUser
            {
                XP             = r.Next(400),
                UserName       = "******" + Counter.ToString() + "@itsligo.ie",
                Email          = "User" + EmailCounter.ToString() + "@itsligo.ie",
                EmailConfirmed = true,
                GamerTag       = "GamerTag" + _usercounter.ToString(),
                PasswordHash   = hasher.HashPassword("Password$" + _usercounter.ToString()),
                SecurityStamp  = Guid.NewGuid().ToString()
            },
                                      new ApplicationUser
            {
                XP             = r.Next(400),
                UserName       = "******" + Counter.ToString() + "@itsligo.ie",
                Email          = "User" + EmailCounter.ToString() + "@itsligo.ie",
                EmailConfirmed = true,
                GamerTag       = "GamerTag" + _usercounter.ToString(),
                PasswordHash   = hasher.HashPassword("Password$" + _usercounter.ToString()),
                SecurityStamp  = Guid.NewGuid().ToString()
            },
                                      new ApplicationUser
            {
                XP             = r.Next(400),
                UserName       = "******" + Counter.ToString() + "@itsligo.ie",
                Email          = "User" + EmailCounter.ToString() + "@itsligo.ie",
                EmailConfirmed = true,
                GamerTag       = "GamerTag" + _usercounter.ToString(),
                PasswordHash   = hasher.HashPassword("Password$" + _usercounter.ToString()),
                SecurityStamp  = Guid.NewGuid().ToString()
            }
                                      );
            context.SaveChanges();
            List <GameScore> scores = new List <GameScore>();
            Game             bg     = context.Games.FirstOrDefault(battle => battle.GameName == "Battle Call");

            if (bg != null)
            {
                foreach (ApplicationUser player in context.Users)
                {
                    //context.GameScores.AddOrUpdate(score => score.PlayerID,
                    scores.Add(new GameScore
                    {
                        PlayerID = player.Id,
                        score    = r.Next(1200),
                        GameID   = bg.GameID
                    }
                               );
                }
                context.GameScores.AddOrUpdate(score => score.PlayerID,
                                               scores.ToArray());

                context.SaveChanges();
            }
        }