Пример #1
0
        public ObjectsDTO GetObjects(int?callerUserId, int?targetUserId, int?folderId)   //, IEnumerable<HistoryItemDTO> history = null)
        {
            if (targetUserId == null)
            {
                if (callerUserId == null)
                {
                    return(null);
                }
                else
                {
                    targetUserId = callerUserId;
                }
            }

            var user       = _users.GetById(targetUserId.Value);
            var currFolder = folderId.HasValue ? _folders.GetById(folderId.Value) : user.Folder;

            if (currFolder == null)
            {
                return(null);
            }
            //var currFolderName = currFolder != null ?
            //    currFolder.Name :
            //    "root";
            //System.IO.File.AppendAllText(@"F:\logs.txt", String.Format("from service:\t\t{0}, {1}, {2}{3}", callerUserId, targetUserId, currFolder.Id, Environment.NewLine));

            var fls        = _folders.GetHierarchyToRoot(currFolder.Id);
            var outHistory = Mapper.Map <IEnumerable <HistoryItemDTO> >(fls).Reverse();

            outHistory.First().Value = rootStringName;
            var folders = GetFolders(callerUserId, user, currFolder);
            var files   = GetFiles(callerUserId, user, currFolder);

            //var userFolders = _folders.GetUserFoldersIds(targetUserId);
            //var outHistory = ManageHistory(history, folderId, currFolderName);

            return(new ObjectsDTO {
                ParentFolderId = currFolder.Id,
                Files = files,
                Folders = folders,
                History = outHistory,
                Parent = Mapper.Map <FolderInfoDTO>(currFolder)
            });
        }