Esempio n. 1
0
        /// <summary>
        /// 创建一个组织
        /// </summary>
        /// <returns></returns>
        public OperationResult CreateOrganization()
        {
            OperationResult result = new OperationResult();

            //1.组织信息初始化
            Create();

            result = Validate();

            //2.创建权限信息

            UserRoleRelation userRoleRelation = CreateUserRoleRelation();

            UserRoleRelations.Add(userRoleRelation);

            //3关键管理员角色权限
            RolePermissionRelations = CreateRolePermission(userRoleRelation.Id);

            //4创建组织和用户的对应关系
            UserOrganizationRelation userOrganizationRelation = new UserOrganizationRelation(Id, MasterUserId);

            userOrganizationRelation.CreateRealtion();

            UserOrganizationRelations.Add(userOrganizationRelation);



            if (!result.Success)
            {
                return(result);
            }

            return(result);
        }
Esempio n. 2
0
        public UserRoleRelation CreateUserRoleRelation()
        {
            var adminRole = Roles.First(x => x.Id == "10000");

            if (adminRole == null)
            {
                throw new Exception("无法找到管理员角色");
            }

            UserRoleRelation roleRelation = new UserRoleRelation(Id, MasterUserId, adminRole.Id);

            roleRelation.CreateUserRoleRelation();
            return(roleRelation);
        }