Пример #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();
            }
        }
Пример #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();
            }
        }
Пример #3
0
 private static void AssociateUserWithAdminRole(UserProfile user, webpages_Roles admin)
 {
     user.webpages_Roles.Add(admin);
 }
Пример #4
0
 private static webpages_Roles CreateAdminRole(UserDbContext context)
 {
     var admin = new webpages_Roles { RoleName = "Administrators" };
     context.webpages_Roles.Add(admin);
     return admin;
 }