Exemple #1
0
        public ActionResult Delete(int id)
        {
            Team team = db.Teams.Find(id);

            db.Teams.Remove(team);
            db.SaveChanges();
            return(View());
        }
Exemple #2
0
        protected override void Seed(ProjectBetterTeams.TeamsContext context)
        {
            UserSignUp pass = new UserSignUp();
            Users      user = new Users()
            {
                Username    = "******",
                Password    = pass.EncryptPassword("Admin"),
                FirstName   = "Panagiotis",
                LastName    = "Papadopoulos",
                DateOFBirth = DateTime.Parse("1992/02/28").Date,
                UserType    = "SuperAdmin"
            };

            using (var db = new TeamsContext())
            {
                db.Users.AddOrUpdate(user);
                db.SaveChanges();
            }
        }
Exemple #3
0
        static void SeedDatabase(TeamsContext ctx)
        {
            Team ferrari = new Team
            {
                Name             = "Ferrari",
                FoundedIn        = 1899,
                CheckPaid        = false,
                ChampionshipsWon = 12
            };

            Team mclaren = new Team
            {
                Name             = "McLaren",
                FoundedIn        = 1910,
                CheckPaid        = true,
                ChampionshipsWon = 3
            };

            Team mercedes = new Team
            {
                Name             = "Mercedes-Benz",
                FoundedIn        = 1960,
                CheckPaid        = true,
                ChampionshipsWon = 25
            };

            //Add admin
            var user = new IdentityUser("admin");

            user.PasswordHash = new PasswordHasher <IdentityUser>().HashPassword(user, ctx.GetService <IConfiguration>().GetSection("Password").Value);
            var userStore = ctx.GetService <UserManager <IdentityUser> >();

            userStore.CreateAsync(user);

            ctx.Add(ferrari);
            ctx.Add(mercedes);
            ctx.Add(mclaren);

            ctx.SaveChanges();

            init = true;
        }
Exemple #4
0
 public ActionResult NewPlayerCreated(Player player)
 {
     db.Players.Add(player);
     db.SaveChanges();
     return(View());
 }