Beispiel #1
0
        public void CreateRole(Role role)
        {
            LoadMetadata();

            RoleMetadata md;
            List<RoleMetadata> mds = this.metadata.Roles.Where(m => m.Id == role.Id).ToList();
            if (mds.Count == 1)
            {
                md = mds[0];
            }
            else
            {
                md = new RoleMetadata();
                this.metadata.Roles.Add(md);
            }

            TranslateToMetadata(md, role);

            SaveMetadata();
        }
Beispiel #2
0
 private static void TranslateToMetadata(RoleMetadata rm, Role role)
 {
     rm.AssignUnassignRole = role.AssignUnassignRole;
     rm.CanCreateRoot = role.CanCreateRoot;
     rm.CanManageSubRoles = role.CanManageSubRoles;
     rm.CanCreateUsers = role.CanCreateUsers;
     rm.ChildRoles = new Collection<ChildId>(role.ChildRoles.Select(id => new ChildId(id)).ToList());
     rm.DataEntities = new Collection<EntityId>(role.DataEntities.Select(id => new EntityId(id)).ToList());
     rm.DataEntityPermission = role.DataEntityPermission;
     rm.Id = role.Id;
     rm.IsRoot = role.IsRoot;
     rm.Name = ConvertBinary(role.Name);
     rm.Users = new Collection<ChildId>(role.Users.Select(id => new ChildId(id)).ToList());
 }
Beispiel #3
0
        private static Role TranslateFromMetadata(RoleMetadata rm)
        {
            Role r = new Role();

            r.AssignUnassignRole = rm.AssignUnassignRole;
            r.CanCreateRoot = rm.CanCreateRoot;
            r.CanManageSubRoles = rm.CanManageSubRoles;
            r.CanCreateUsers = rm.CanCreateUsers;
            r.ChildRoles = rm.ChildRoles.Select(c => c.Id).ToList();
            r.DataEntities = rm.DataEntities.Select(d => d.Id).ToList();
            r.DataEntityPermission = rm.DataEntityPermission;
            r.Id = rm.Id;
            r.IsRoot = rm.IsRoot;
            r.Name = ConvertBinary(rm.Name);
            r.Users = rm.Users.Select(u => u.Id).ToList();

            return r;
        }