Example #1
0
        public INode GetByID(int nodeID, int userID)
        {
            if (_permissionService.HasNodePermission(nodeID, userID))
            {
                return(_dataItemRepository.GetByID(nodeID));
            }

            return(null);
        }
        public bool HasNodePermission(int nodeID, int userID)
        {
            if (_userRepository.GetByID(userID).IsAdministrator)
            {
                return(true);
            }

            bool hasPermission = false;
            var  node          = _dataItemRepository.GetByID(nodeID);

            hasPermission = _userDataItemRepository.HasPermission(nodeID, userID);

            while (node.ParentFolderID.HasValue && !hasPermission)
            {
                node          = _dataItemRepository.GetByID(node.ParentFolderID.Value);
                hasPermission = _userDataItemRepository.HasPermission(node.ID, userID);
            }

            return(hasPermission);
        }