protected FoldersModel GetFoldersModel()
        {
            var member = CurrentMember;

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

            // Get the folders and their counts.

            var folderData = new Dictionary <Guid, FolderDataModel>();

            // Flag list.

            var flagList = _jobAdFlagListsQuery.GetFlagList(member);
            var count    = _jobAdFlagListsQuery.GetFlaggedCount(member);

            folderData[flagList.Id] = new FolderDataModel {
                Count = count, CanRename = false
            };

            // Folders.

            var folders       = _jobAdFoldersQuery.GetFolders(member);
            var counts        = _jobAdFoldersQuery.GetInFolderCounts(member);
            var lastUsedTimes = _jobAdFoldersQuery.GetLastUsedTimes(member);

            foreach (var folder in folders)
            {
                folderData[folder.Id] = new FolderDataModel
                {
                    Count     = GetCount(folder.Id, counts),
                    CanRename = _jobAdFoldersCommand.CanRenameFolder(member, folder),
                };
            }

            var comparer = new FolderComparer(lastUsedTimes);

            return(new FoldersModel
            {
                FlagList = flagList,
                MobileFolder = folders.Single(f => f.FolderType == FolderType.Mobile),
                PrivateFolders = folders.Where(f => f.FolderType == FolderType.Private).OrderBy(f => f, comparer).ToList(),
                FolderData = folderData,
            });
        }
Esempio n. 2
0
        protected void AssertFolderEntries(IMember member, JobAdFolder folder, ICollection <IJobAd> inFolderJobAds, ICollection <IJobAd> notInFolderJobAds)
        {
            // IsInFolder

            foreach (var inFolderJobAd in inFolderJobAds)
            {
                Assert.IsTrue(_jobAdFoldersQuery.IsInFolder(member, folder.Id, inFolderJobAd.Id));
            }
            foreach (var notInFolderJobAd in notInFolderJobAds)
            {
                Assert.IsFalse(_jobAdFoldersQuery.IsInFolder(member, folder.Id, notInFolderJobAd.Id));
            }

            // GetInFolderJobAdIds

            Assert.IsTrue((from m in inFolderJobAds select m.Id).CollectionEqual(_jobAdFoldersQuery.GetInFolderJobAdIds(member, folder.Id)));

            // GetInFolderCounts.

            var counts = _jobAdFoldersQuery.GetInFolderCounts(member);

            Assert.AreEqual(inFolderJobAds.Count, counts.ContainsKey(folder.Id) ? counts[folder.Id] : 0);
        }