Exemple #1
0
 private static void SelectFunctionItems(RoleDTO role, DataServiceCollection<FunctionItemDTO> functionItems)
 {
     for (int i = functionItems.Count - 1; i >= 0; i--)
     {
         var temp = functionItems[i];
         if (role.RoleFunctions.All(p => p.FunctionItemId != temp.Id))
         {
             functionItems.Remove(temp);
             continue;
         }
         SelectFunctionItems(role, temp.SubFunctionItems);
     }
 }
 protected void OnAddRole(object obj)
 {
     Role = new RoleDTO
     {
         Id = RandomHelper.Next(),
     };
     Roles.AddNew(Role);
 }
 public void AddOrganizationRole()
 {
     if (Organization != null && Role != null)
     {
         if (Organization.OrganizationRoles.All(p => p.RoleId != Role.Id))
         {
             var userRole = new OrganizationRoleDTO
             {
                 Id = RandomHelper.Next(),
                 OrganizationId = Organization.Id,
                 RoleId = Role.Id
             };
             Organization.OrganizationRoles.Add(userRole);
             OrganizationRole = new RoleDTO
             {
                 Name = Role.Name,
                 RoleFunctions = Role.RoleFunctions
             };
             var tempUserRoles = OrganizationRoles ?? new ObservableCollection<RoleDTO>();
             tempUserRoles.Add(OrganizationRole);
             OrganizationRoles = tempUserRoles;
         }
         else
         {
             MessageAlert("当前组织机构已有该角色!");
         }
     }
 }
Exemple #4
0
 public void AddUserRole()
 {
     if (User != null && Role != null)
     {
         if (User.UserRoles.All(p => p.RoleId != Role.Id))
         {
             var userRole = new UserRoleDTO
             {
                 Id = RandomHelper.Next(),
                 UserId = User.Id,
                 RoleId = Role.Id
             };
             User.UserRoles.Add(userRole);
             UserRole = new RoleDTO
             {
                 Name = Role.Name,
                 RoleFunctions = Role.RoleFunctions
             };
             var tempUserRoles = UserRoles ?? new ObservableCollection<RoleDTO>();
             tempUserRoles.Add(UserRole);
             UserRoles = tempUserRoles;
         }
         else
         {
             MessageAlert("当前用户已有该角色!");
         }
     }
 }