public ActionResult BlockJobAds(Guid[] jobAdIds)
        {
            try
            {
                // Look for the blocklist.

                var member    = CurrentMember;
                var blockList = _jobAdBlockListsQuery.GetBlockList(member);
                if (blockList == null)
                {
                    return(JsonNotFound("blocklist"));
                }

                // Add jobads.

                var count = _memberJobAdListsCommand.AddJobAdsToBlockList(member, blockList, jobAdIds);
                return(Json(new JsonCountModel {
                    Count = count
                }));
            }
            catch (UserException ex)
            {
                ModelState.AddModelError(ex, new StandardErrorHandler());
            }

            return(Json(new JsonResponseModel()));
        }
        public void TestJobAdCount()
        {
            const int count = 5;

            var member = CreateMember(1);
            var folder = GetFolder(member, 1);

            var employer = CreateEmployer(0);
            var jobAd1   = _jobAdsCommand.PostTestJobAd(employer);

            _candidateListsCommand.AddJobAdToFolder(member, folder, jobAd1.Id);

            for (var i = 1; i < count; i++)
            {
                _candidateListsCommand.AddJobAdToFolder(member, folder, _jobAdsCommand.PostTestJobAd(employer).Id);
            }

            Assert.AreEqual(count, _jobAdFoldersQuery.GetInFolderCounts(member)[folder.Id]);

            // Now block the member permanently.

            var blockList = _jobAdBlockListsQuery.GetBlockList(member);

            Assert.AreEqual(1, _candidateListsCommand.AddJobAdToBlockList(member, blockList, jobAd1.Id));

            Assert.AreEqual(1, _jobAdBlockListsQuery.GetBlockedCount(member));
            Assert.AreEqual(count - 1, _jobAdFoldersQuery.GetInFolderCounts(member)[folder.Id]);
        }
        public void TestJobAdCount()
        {
            const int count = 5;

            var member   = CreateMember(1);
            var flagList = _jobAdFlagListsQuery.GetFlagList(member);

            var employer = CreateEmployer(0);
            var jobAd1   = _jobAdsCommand.PostTestJobAd(employer);

            _memberJobAdListsCommand.AddJobAdToFlagList(member, flagList, jobAd1.Id);
            for (var i = 1; i < count; i++)
            {
                _memberJobAdListsCommand.AddJobAdToFlagList(member, flagList, _jobAdsCommand.PostTestJobAd(employer).Id);
            }

            Assert.AreEqual(count, _jobAdFlagListsQuery.GetFlaggedCount(member));

            // Now block the member permanently.

            var blockList = _jobAdBlockListsQuery.GetBlockList(member);

            Assert.AreEqual(1, _memberJobAdListsCommand.AddJobAdToBlockList(member, blockList, jobAd1.Id));

            Assert.AreEqual(1, _jobAdBlockListsQuery.GetBlockedCount(member));
            Assert.AreEqual(count - 1, _jobAdFlagListsQuery.GetFlaggedCount(member));
        }
Beispiel #4
0
        private void CreateLists(IMember member)
        {
            _blockList = _jobAdBlockListsQuery.GetBlockList(member);
            _flagList  = _jobAdFlagListsQuery.GetFlagList(member);

            var folders = _jobAdFoldersQuery.GetFolders(member);

            _folder1 = folders[1];
            _folder2 = folders[2];
        }
Beispiel #5
0
        public void TestFilterBlockIsFlagged()
        {
            var employer = CreateEmployer(0);
            var jobAd    = _jobAdsCommand.PostTestJobAd(employer);
            var member   = _membersCommand.CreateTestMember(1);

            // Member in folder.

            var flagList = _jobAdFlagListsQuery.GetFlagList(member);

            _memberJobAdListsCommand.AddJobAdToFlagList(member, flagList, jobAd.Id);

            // Filter.

            TestFilter(new[] { jobAd.Id }, member, CreateIsFlaggedQuery(true), new[] { jobAd.Id });

            // Block.

            _memberJobAdListsCommand.AddJobAdToBlockList(member, _jobAdBlockListsQuery.GetBlockList(member), jobAd.Id);
            TestFilter(new Guid[0], member, CreateIsFlaggedQuery(true), new[] { jobAd.Id });
        }
        public void TestFilterBlockListId()
        {
            var employer = CreateEmployer(0);
            var jobAd1   = _jobAdsCommand.PostTestJobAd(employer);
            var jobAd2   = _jobAdsCommand.PostTestJobAd(employer);
            var member   = _membersCommand.CreateTestMember(1);

            // jobAd1 in blockList.

            var blockList = _jobAdBlockListsQuery.GetBlockList(member);

            _memberJobAdListsCommand.AddJobAdToBlockList(member, blockList, jobAd1.Id);

            // Filter.

            TestBlockedFilter(new[] { jobAd1.Id }, member, new[] { jobAd1.Id, jobAd2.Id });
        }
Beispiel #7
0
        private BlockListListModel BlockListResults(JobAdSearchSortCriteria sortCriteria, JobAdsPresentationModel presentation)
        {
            var member    = CurrentMember;
            var blockList = _jobAdBlockListsQuery.GetBlockList(member);

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

            // Do a search to get the jobads in this blockList.

            var model = Sort(member, sortCriteria, presentation);

            model.BlockList   = blockList;
            model.Folders     = GetFoldersModel();
            model.BlockLists  = GetBlockListsModel();
            model.SortOrders  = SortOrders;
            model.Communities = _communitiesQuery.GetCommunities().ToDictionary(c => c.Id, c => c);
            model.Verticals   = _verticalsQuery.GetVerticals().ToDictionary(v => v.Id, v => v);
            return(model);
        }
        protected BlockListsModel GetBlockListsModel()
        {
            var member = CurrentMember;

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

            var blockList = _jobAdBlockListsQuery.GetBlockList(member);

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

            var blockListEntriesCount = _jobAdBlockListsQuery.GetBlockedCount(member);

            return(new BlockListsModel
            {
                BlockList = blockList,
                BlockListCount = new Tuple <Guid, int> (blockList.Id, blockListEntriesCount),
            });
        }
Beispiel #9
0
 protected override void UpdateJobAds(IMember member, IEnumerable <Guid> jobAdIds)
 {
     _memberJobAdListsCommand.AddJobAdsToBlockList(member, _jobAdBlockListsQuery.GetBlockList(member), jobAdIds);
 }
Beispiel #10
0
 protected JobAdBlockList GetBlockList(IMember member)
 {
     return(_jobAdBlockListsQuery.GetBlockList(member));
 }