コード例 #1
0
        protected void AssertFolderEntries(IEmployer employer, CandidateFolder folder, ICollection <Member> inFolderMembers, ICollection <Member> notInFolderMembers)
        {
            // IsInFolder

            foreach (var inFolderMember in inFolderMembers)
            {
                Assert.IsTrue(_candidateFoldersQuery.IsInFolder(employer, folder.Id, inFolderMember.Id));
            }
            foreach (var notInFolderMember in notInFolderMembers)
            {
                Assert.IsFalse(_candidateFoldersQuery.IsInFolder(employer, folder.Id, notInFolderMember.Id));
            }

            if (folder.FolderType == FolderType.Mobile)
            {
                foreach (var member in inFolderMembers)
                {
                    Assert.IsTrue(_candidateFoldersQuery.IsInMobileFolder(employer, member.Id));
                }
                foreach (var member in notInFolderMembers)
                {
                    Assert.IsFalse(_candidateFoldersQuery.IsInMobileFolder(employer, member.Id));
                }
            }

            // GetInFolderCandidateIds

            Assert.IsTrue((from m in inFolderMembers select m.Id).CollectionEqual(_candidateFoldersQuery.GetInFolderCandidateIds(employer, folder.Id)));
            if (folder.FolderType == FolderType.Mobile)
            {
                Assert.IsTrue((from m in inFolderMembers select m.Id).CollectionEqual(_candidateFoldersQuery.GetInMobileFolderCandidateIds(employer, from m in inFolderMembers.Concat(notInFolderMembers) select m.Id)));
            }

            // GetInFolderCounts.

            var counts = _candidateFoldersQuery.GetInFolderCounts(employer);

            if (counts.ContainsKey(folder.Id))
            {
                Assert.AreEqual(inFolderMembers.Count, counts[folder.Id]);
            }
            else
            {
                Assert.AreEqual(inFolderMembers.Count, 0);
            }
        }
コード例 #2
0
        public ActionResult Folders()
        {
            var employer = CurrentEmployer;

            // Treat the flag list as a special folder.

            var flagList = _candidateFlagListsQuery.GetFlagList(employer);
            var count    = _candidateFlagListsQuery.GetFlaggedCount(employer);

            // Get the folders and their counts.

            var folders       = _candidateFoldersQuery.GetFolders(employer);
            var counts        = _candidateFoldersQuery.GetInFolderCounts(employer);
            var lastUsedTimes = _candidateFoldersQuery.GetLastUsedTimes(employer);

            var flagListModels = flagList == null
                ? new FolderModel[0]
                : new []
            {
                new FolderModel
                {
                    Id        = flagList.Id,
                    Name      = null,
                    Type      = flagList.FlagListType.ToString(),
                    CanDelete = false,
                    CanRename = false,
                    Count     = count
                }
            };

            var folderModels = folders
                               .OrderBy(f => f, new FolderComparer(lastUsedTimes))
                               .Select(f => new FolderModel
            {
                Id        = f.Id,
                Name      = f.Name,
                Type      = f.FolderType.ToString(),
                CanDelete = _candidateFoldersCommand.CanDeleteFolder(employer, f),
                CanRename = _candidateFoldersCommand.CanRenameFolder(employer, f),
                Count     = GetCount(f.Id, counts),
            });

            return(Json(new JsonFoldersModel {
                Folders = flagListModels.Concat(folderModels).ToList()
            }));
        }
コード例 #3
0
        public ActionResult Folders()
        {
            var employer = CurrentEmployer;

            // Get the folders and their counts.

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

            // Flag list.

            var flagList = _candidateFlagListsQuery.GetFlagList(employer);
            var count    = _candidateFlagListsQuery.GetFlaggedCount(employer);

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

            // Folders.

            var folders       = _candidateFoldersQuery.GetFolders(employer);
            var counts        = _candidateFoldersQuery.GetInFolderCounts(employer);
            var lastUsedTimes = _candidateFoldersQuery.GetLastUsedTimes(employer);

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

            var comparer = new FolderComparer(lastUsedTimes);

            return(View(new FoldersModel
            {
                FlagList = flagList,
                ShortlistFolder = (from f in folders where f.FolderType == FolderType.Shortlist select f).SingleOrDefault(),
                PrivateFolders = (from f in folders where f.FolderType == FolderType.Private || f.FolderType == FolderType.Mobile select f).OrderBy(f => f, comparer).ToList(),
                SharedFolders = (from f in folders where f.FolderType == FolderType.Shared select f).OrderBy(f => f, comparer).ToList(),
                FolderData = folderData,
            }));
        }