Esempio n. 1
0
        private void CreateAdminAndAssociateUser(UserDbContext context)
        {
            var admin = new webpages_Roles {RoleName = _administrators};
            context.webpages_Roles.Add(admin);

            bool moreThanOneUserExists = context.UserProfiles.Count() != 1;

            var user = GetUserByName(context);
            if (user != null && !moreThanOneUserExists)
            {
                user.webpages_Roles.Add(admin);
            }

            context.SaveChanges();

            if (moreThanOneUserExists)
            {
                throw new CanNotCreateAdministratorException();
            }
        }
Esempio n. 2
0
        private void CreateAdminAndAssociateUser(UserDbContext context)
        {
            var admin = new webpages_Roles {
                RoleName = _administrators
            };

            context.webpages_Roles.Add(admin);

            bool moreThanOneUserExists = context.UserProfiles.Count() != 1;

            var user = GetUserByName(context);

            if (user != null && !moreThanOneUserExists)
            {
                user.webpages_Roles.Add(admin);
            }

            context.SaveChanges();

            if (moreThanOneUserExists)
            {
                throw new CanNotCreateAdministratorException();
            }
        }
Esempio n. 3
0
 private static void AssociateUserWithAdminRole(UserProfile user, webpages_Roles admin)
 {
     user.webpages_Roles.Add(admin);
 }
Esempio n. 4
0
 private static webpages_Roles CreateAdminRole(UserDbContext context)
 {
     var admin = new webpages_Roles { RoleName = "Administrators" };
     context.webpages_Roles.Add(admin);
     return admin;
 }