Exemple #1
0
 private void AssertCounts(IMember member, int blockListCount, int flagListCount, int folder1Count, int folder2Count)
 {
     Assert.AreEqual(blockListCount, _jobAdBlockListsQuery.GetBlockedCount(member));
     Assert.AreEqual(flagListCount, _jobAdFlagListsQuery.GetFlaggedCount(member));
     Assert.AreEqual(folder1Count, _jobAdFoldersQuery.GetInFolderCount(member, _folder1.Id));
     Assert.AreEqual(folder2Count, _jobAdFoldersQuery.GetInFolderCount(member, _folder2.Id));
 }
Exemple #2
0
        private 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,
            });
        }
        public ActionResult RemoveCurrentJobAds()
        {
            try
            {
                // Look for the flaglist.

                var member = CurrentMember;

                int count;
                var currentSearch = MemberContext.CurrentSearch;

                if (currentSearch != null)
                {
                    var flagList = _jobAdFlagListsQuery.GetFlagList(member);

                    // Search for jobads in the current search and flag list.

                    var criteria  = (JobAdSearchCriteria)((ICloneable)currentSearch.Criteria).Clone();
                    var execution = _executeJobAdSearchCommand.SearchFlagged(member, criteria, null);

                    // Remove those returned from the flag list.

                    count = _memberJobAdListsCommand.RemoveJobAdsFromFlagList(member, flagList, execution.Results.JobAdIds);
                }
                else
                {
                    count = _jobAdFlagListsQuery.GetFlaggedCount(member);
                }

                return(Json(new JsonCountModel {
                    Count = count
                }));
            }
            catch (UserException ex)
            {
                ModelState.AddModelError(ex, new StandardErrorHandler());
            }

            return(Json(new JsonResponseModel()));
        }
        protected void AssertFlagListEntries(IMember member, ICollection <IJobAd> isFlaggedJobAds, ICollection <IJobAd> isNotFlaggedJobAds)
        {
            // IsFlagged.

            foreach (var isFlaggedJobAd in isFlaggedJobAds)
            {
                Assert.IsTrue(_jobAdFlagListsQuery.IsFlagged(member, isFlaggedJobAd.Id));
            }
            foreach (var isNotFlaggedMember in isNotFlaggedJobAds)
            {
                Assert.IsFalse(_jobAdFlagListsQuery.IsFlagged(member, isNotFlaggedMember.Id));
            }

            // GetFlaggedCount.

            Assert.AreEqual(isFlaggedJobAds.Count, _jobAdFlagListsQuery.GetFlaggedCount(member));

            // GetFlaggedCandidateIds.

            Assert.IsTrue((from j in isFlaggedJobAds select j.Id).CollectionEqual(_jobAdFlagListsQuery.GetFlaggedJobAdIds(member)));
            Assert.IsTrue((from j in isFlaggedJobAds select j.Id).CollectionEqual(_jobAdFlagListsQuery.GetFlaggedJobAdIds(member, from j in isFlaggedJobAds.Concat(isNotFlaggedJobAds) select j.Id)));
        }