public void DeleteRole(string roleId)
 {
     using (var context = RepositoryContext.Create())
     {
         var repository = context.GetRepository<RoleRepository>();
         Role role = repository.Get(roleId);
         var userContextDomainService = new UserContexDomainService();
         userContextDomainService.DeleteRole(role);
     }
 }
        public bool AssignRole(string userId, string roleId)
        {
            if (string.IsNullOrWhiteSpace(userId))
            {
                throw new ArgumentNullException("userId");
            }
            if (string.IsNullOrWhiteSpace(roleId))
            {
                throw new ArgumentNullException("roleId");
            }

            using (var context = RepositoryContext.Create())
            {
                var roleRepository = context.GetRepository<RoleRepository>();
                var userRepository = context.GetRepository<UserRepository<User>>();
                User user = userRepository.Get(userId);
                Role role = roleRepository.Get(roleId);

                var domainService = new UserContexDomainService();
                return domainService.AssignRole(user, role);
            }
        }
        public void UnassignAllRole(string userId)
        {
            if (string.IsNullOrWhiteSpace(userId))
            {
                throw new ArgumentNullException("userId");
            }

            using (var context = RepositoryContext.Create())
            {
                var repository = context.GetRepository<UserRepository<User>>();
                User user = repository.Get(userId);

                var domainService = new UserContexDomainService();
                domainService.UnassignAllRole(user);
            }
        }