Beispiel #1
0
        //private IEnumerable<HistoryItemDTO> ManageHistory(IEnumerable<HistoryItemDTO> history, int? folderId, string folderName)
        //{
        //    if (history == null)
        //        history = Enumerable.Empty<HistoryItemDTO>();

        //    if (!history.Any(i => i.Id == folderId))
        //        history = history.Append(new HistoryItemDTO() { Id = folderId, Value = folderName });
        //    else
        //        history = history.TakeWhileInclude(w => w.Id != folderId);

        //    return history.ToList();
        //}
        //public bool IsAccessibleByVisibility(int? caller, int target, FileAccess vis)
        //{
        //    switch (vis)
        //    {
        //        case FileAccess.Private:
        //            return target == caller;
        //        case FileAccess.Public:
        //            return true;
        //        case FileAccess.RegisteredUsers:
        //            return caller.HasValue;
        //        default:
        //            throw new NotImplementedException();
        //    }
        //}

        private IEnumerable <FolderDTO> GetFolders(int?callerUserId, User targetUser, Folder folder)
        {
            //здесь не может быть callerUserId == null && targetUser.Id == null
            IEnumerable <Folder> folders = null;

            if (!_verifier.IsAccessibleByVisibility(callerUserId, targetUser.Id, folder.Visibility))
            {
                //throw new UnauthorizedAccessException("Вы попытались получить доступ к папке, к которой не имеете доступа.");
                return(null);
            }
            folders = _folders.GetByPredicate(f => f.ParentFolder != null && f.ParentFolder.Id == folder.Id)
                      .Where(f => _verifier.IsAccessibleByVisibility(callerUserId, targetUser.Id, f.Visibility));
            //if (callerUserId == targetUser.Id)
            //    folders = _folders.GetByPredicate(f => f.ParentFolder != null && f.ParentFolder.Id == folder.Id);
            //else

            if (folders == null)
            {
                return(null);
            }

            return(Mapper.Map <IEnumerable <FolderDTO> >(folders));
        }
Beispiel #2
0
        public IQueryable <IBllFolder> GetFoldersOfUser(string userName, int?rootFolderId)
        {
            var userId = _userService.GetUserByName(userName).Id;

            return(_folderRepository.GetByPredicate(f => f.UserId == userId && f.RootFolderId == rootFolderId).Select(BllMappers.ToBllFolderExpression()));
        }
Beispiel #3
0
 public IEnumerable <DtoFolder> GetFoldersByPredicate(Expression <Func <DtoFolder, bool> > func)
 => folderRepository.GetByPredicate(Convert <DtoFolder, DalFolder>(func)).Select(item => item.ToDtoFolder());