Пример #1
0
 public void InsertRole(RoleDTO role)
 {
     var newRole = RoleFactory.CreateRole(role.Name);
     newRole.ChangeCurrentIdentity(role.Id);
     role.RoleFunctions.ToList()
         .ForEach(roleFunction => _roleFunctionRepository.Add(new RoleFunction(role.Id, roleFunction.FunctionItemId)));
     _roleRepository.Add(newRole);
 }
Пример #2
0
        public void ModifyRole(RoleDTO role)
        {
            var updateRole = _roleRepository.Get(role.Id);
            updateRole.UpdateRole(role.Name, role.Description, role.IsSystemRole);

            var dtoRoleFunctions = role.RoleFunctions;
            var roleFunctions = updateRole.RoleFunctions;
            DataHelper.DetailHandle(dtoRoleFunctions.ToArray(),
                roleFunctions.ToArray(),
                c => c.Id, p => p.Id,
                i => InsertRoleFunction(updateRole, i),
                (c, p) => UpdateRoleFunction(c),
                d => _roleRepository.DeleteRoleFunction(d));
            _roleRepository.Modify(updateRole);
        }
Пример #3
0
 public void DeleteRole(RoleDTO role)
 {
     var deleteRole = _roleRepository.Get(role.Id); //获取需要删除的对象。
     _roleRepository.DeleteRole(deleteRole); //删除Role。
 }