示例#1
0
        public ActionResult Search(JobAdSearchCriteria criteria, JobAdsPresentationModel presentation)
        {
            var member = CurrentMember;

            // Prepare.

            var criteriaIsEmpty = PrepareCriteria(criteria);

            presentation = PreparePresentationModel(presentation);

            if (criteriaIsEmpty || !ModelState.IsValid)
            {
                // Set up defaults.

                SetDefaults(criteria);

                if (member != null && MemberContext.ShowUpdatedTermsReminder())
                {
                    ModelState.AddModelConfirmation("We've made some changes to our terms and conditions. You can review them <a href=\"" + SupportRoutes.Terms.GenerateUrl() + "\">here</a>.");
                }

                return(View(GetSearchModel(criteria, presentation)));
            }

            MemberContext.CurrentSearch = new JobAdSearchNavigation(criteria, presentation);
            MemberContext.IsNewSearch   = true;

            return(RedirectToRoute(SearchRoutes.Results));
        }
示例#2
0
        private static JobAdsPresentationModel PreparePresentationModel(JobAdsPresentationModel model)
        {
            // Ensure that the pagination values are always set.

            if (model == null)
            {
                model = new JobAdsPresentationModel();
            }
            if (model.Pagination == null)
            {
                model.Pagination = new Pagination();
            }
            if (model.Pagination.Page == null)
            {
                model.Pagination.Page = 1;
            }
            if (model.Pagination.Items == null)
            {
                model.Pagination.Items = Reference.DefaultItemsPerPage;
            }
            model.ItemsPerPage        = Reference.ItemsPerPage;
            model.DefaultItemsPerPage = Reference.DefaultItemsPerPage;

            return(model);
        }
示例#3
0
        public ActionResult Results()
        {
            var search = MemberContext.CurrentSearch;

            if (search == null)
            {
                return(View("NoCurrentSearch"));
            }

            var presentation = new JobAdsPresentationModel
            {
                Pagination = search.Pagination
            };

            var member = CurrentMember;

            if (MemberContext.IsNewSearch)
            {
                // Do a search based on the criteria.

                var searchList = Search(SearchContext.NewSearch, member, search.Criteria, presentation, null, JobAdListType.SearchResult);

                // Get suggestions as needed.

                return(View("Results", searchList));
            }

            // Not a new search.

            return(View("Results", Search(SearchContext.Current, member, search.Criteria, PreparePresentationModel(presentation), null, JobAdListType.SearchResult)));
        }
示例#4
0
        private SuggestedJobsListModel GetSuggestedJobs(JobAdsPresentationModel presentation)
        {
            var model = SuggestedJobs <SuggestedJobsListModel>(CurrentMember, PreparePresentationModel(presentation));

            model.Industries = _industriesQuery.GetIndustries();
            return(model);
        }
示例#5
0
        private SimilarJobsListModel GetSimilarJobs(IMember member, Guid jobAdId, JobAdsPresentationModel presentation)
        {
            var model = SimilarJobs <SimilarJobsListModel>(member, jobAdId, PreparePresentationModel(presentation));

            model.Industries = _industriesQuery.GetIndustries();
            model.JobAdId    = jobAdId;
            return(model);
        }
示例#6
0
        private BrowseListModel Browse(IMember member, JobAdSearchCriteria criteria, JobAdsPresentationModel presentation, JobAdListType listType)
        {
            var browseList = GetSearchList(Search <BrowseListModel>(member, PrepareCriteriaForSearch(criteria), presentation, listType));

            // Save the basis for the search.

            MemberContext.CurrentSearch = new JobAdSearchNavigation(browseList.Criteria, browseList.Presentation);
            return(browseList);
        }
示例#7
0
        public ActionResult BlockList(JobAdSearchSortCriteria sortCriteria, JobAdsPresentationModel presentation)
        {
            var model = BlockListResults(sortCriteria, presentation);

            if (model == null)
            {
                return(NotFound("blocklist"));
            }

            MemberContext.CurrentJobAds = new BlockListNavigation(presentation);
            return(View("BlockList", model));
        }
示例#8
0
        private SearchModel GetSearchModel(JobAdSearchCriteria criteria, JobAdsPresentationModel presentationModel)
        {
            var suggestedJobs = GetSuggestedJobs(CurrentMember);

            return(new SearchModel
            {
                Criteria = criteria,
                Presentation = presentationModel,
                ListType = JobAdListType.SearchResult,
                AncillaryData = GetAncillaryData(),
                SuggestedJobs = suggestedJobs,
            });
        }
示例#9
0
        public ActionResult MobileFolder(JobAdSearchSortCriteria sortCriteria, JobAdsPresentationModel presentation)
        {
            var member = CurrentMember;
            var folder = _jobAdFoldersQuery.GetMobileFolder(member);
            if (folder == null)
                return NotFound("folder");

            var model = FolderResults(folder.Id, sortCriteria, presentation);
            if (model == null)
                return NotFound("folder", "id", folder.Id);

            MemberContext.CurrentJobAds = new FolderNavigation(folder.Id, presentation);
            return View(model);
        }
示例#10
0
        public ActionResult LeftSide()
        {
            var search = MemberContext.CurrentSearch;

            if (search == null)
            {
                //There should always be a curent search but it's possible for a spider to hit this link
                return(RedirectToRoute(SearchRoutes.Search));
            }

            var presentation = new JobAdsPresentationModel
            {
                Pagination = search.Pagination
            };

            var member = CurrentMember;

            // Not a new search.
            return(View("LeftSide", Search(SearchContext.Current, member, search.Criteria, PreparePresentationModel(presentation), null, JobAdListType.SearchResult)));
        }
示例#11
0
        public ActionResult Search(JobAdSearchCriteria criteria, JobAdsPresentationModel presentation)
        {
            try
            {
                presentation = PreparePresentationModel(presentation);
                criteria.PrepareCriteria();

                var execution = _executeJobAdSearchCommand.Search(CurrentMember, criteria, presentation.Pagination.ToRange());

                SaveSearch(SearchContext.Filter, CurrentMember, execution.Results, criteria, presentation.Pagination.Page.Value);
                MemberContext.CurrentSearch = new JobAdSearchNavigation(criteria, presentation);

                // Be sure to maintain the order of the search.

                var views  = _memberJobAdViewsQuery.GetMemberJobAdViews(CurrentMember, execution.Results.JobAdIds).ToDictionary(v => v.Id, v => v);
                var jobAds = (from i in execution.Results.JobAdIds
                              select views[i]).ToList();

                var model = new JsonJobAdsResponseModel
                {
                    TotalJobAds      = execution.Results.TotalMatches,
                    IndustryHits     = execution.Results.IndustryHits.ToDictionary(i => i.Key.ToString(), i => i.Value),
                    JobTypeHits      = GetEnumHitsDictionary(execution.Results.JobTypeHits, JobTypes.All, JobTypes.None),
                    JobAds           = jobAds,
                    CriteriaHtml     = criteria.GetCriteriaHtml(),
                    Hash             = criteria.GetHash(),
                    QueryStringForGa = new AdSenseQueryGenerator(new JobAdSearchCriteriaAdSenseConverter()).GenerateAdSenseQuery(criteria)
                };

                return(Json(model, JsonRequestBehavior.AllowGet));
            }
            catch (UserException ex)
            {
                ModelState.AddModelError(ex, new StandardErrorHandler());
            }

            return(Json(new JsonResponseModel()));
        }
示例#12
0
        public ActionResult PartialSearch(JobAdSearchCriteria criteria, JobAdsPresentationModel presentation)
        {
            var member = CurrentMember;

            // Prepare.

            var criteriaIsEmpty = PrepareCriteria(criteria);

            presentation = PreparePresentationModel(presentation);
            SearchListModel model;

            if (criteriaIsEmpty)
            {
                // Set up defaults.

                SetDefaults(criteria);
                model = CreateEmptyList <SearchListModel>(member, criteria, presentation, JobAdListType.SearchResult);
                return(View("JobAdList", model));
            }

            model = Search(SearchContext.Filter, member, criteria, presentation, null, JobAdListType.SearchResult);
            return(PartialView("JobAdList", model));
        }
示例#13
0
 private FolderListModel Sort(IMember member, Guid folderId, JobAdSearchSortCriteria criteria, JobAdsPresentationModel presentation)
 {
     return(Sort <FolderListModel>(
                member,
                criteria ?? new JobAdSearchSortCriteria {
         SortOrder = DefaultSortOrder
     },
                presentation,
                JobAdListType.Folder,
                (m, c, r) => _executeJobAdSortCommand.SortFolder(m, folderId, c, r)));
 }
示例#14
0
        protected FolderListModel FolderResults(Guid folderId, JobAdSearchSortCriteria sortCriteria, JobAdsPresentationModel presentation)
        {
            var member = CurrentMember;
            var folder = _jobAdFoldersQuery.GetFolder(member, folderId);

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

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

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

            model.Folder      = folder;
            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);
        }
示例#15
0
 public ActionResult SuggestedJobsPartial(JobAdsPresentationModel presentation)
 {
     return(PartialView("JobAdList", GetSuggestedJobs(presentation)));
 }
示例#16
0
        protected TListModel Sort <TListModel>(IMember member, JobAdSearchSortCriteria criteria, JobAdsPresentationModel presentation, JobAdListType listType, Func <IMember, JobAdSearchSortCriteria, Range, JobAdSortExecution> sort)
            where TListModel : JobAdSortListModel, new()
        {
            presentation = PreparePresentationModel(presentation);

            // Search.

            var execution = sort(member, criteria, presentation.Pagination.ToRange());

            var model = new TListModel
            {
                ListType     = listType,
                Criteria     = execution.Criteria,
                Presentation = presentation,
                Results      = new JobAdListResultsModel
                {
                    TotalJobAds = execution.Results.TotalMatches,
                    JobAdIds    = execution.Results.JobAdIds,
                    JobAds      = GetMemberJobAdViews(member, execution.Results.JobAdIds),
                },
                Industries = _industriesQuery.GetIndustries(),
            };

            return(model);
        }
示例#17
0
 public JobAdNavigation(Guid jobAdId, JobAdsPresentationModel presentation)
     : base(presentation)
 {
     JobAdId = jobAdId;
 }
示例#18
0
 public FolderNavigation(Guid folderId, JobAdsPresentationModel presentation)
     : base(presentation)
 {
     FolderId = folderId;
 }
示例#19
0
 public ActionResult SimilarJobs(Guid jobAdId, JobAdsPresentationModel presentation)
 {
     return(View(GetSimilarJobs(CurrentMember, jobAdId, presentation)));
 }
示例#20
0
 public FlagListNavigation(JobAdsPresentationModel presentation)
     : base(presentation)
 {
 }
示例#21
0
 public ActionResult SimilarJobsPartial(Guid jobAdId, JobAdsPresentationModel presentation)
 {
     return(PartialView("JobAdList", GetSimilarJobs(CurrentMember, jobAdId, presentation)));
 }