Ejemplo n.º 1
0
        protected static CandidatesPresentationModel PreparePresentationModel(CandidatesPresentationModel model)
        {
            // Ensure that the pagination values are always set.

            if (model == null)
            {
                model = new CandidatesPresentationModel();
            }
            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);
        }
Ejemplo n.º 2
0
        public ActionResult Search(MemberSearchCriteria criteria, CandidatesPresentationModel presentation, bool?createEmailAlert)
        {
            var employer = CurrentEmployer;

            // Prepare.

            var criteriaIsEmpty = PrepareCriteria(employer, criteria);

            presentation = PreparePresentationModel(presentation);

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

                SetDefaults(criteria);

                if (CurrentEmployer != null && EmployerContext.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(GetSearchList(employer, createEmailAlert, criteria, presentation)));
            }

            // On a new search reset.

            EmployerContext.CurrentSearch = new MemberSearchNavigation(criteria, presentation);
            ResetSearch(employer, null);

            return(createEmailAlert != null
                ? RedirectToRoute(SearchRoutes.Results, new { createEmailAlert })
                : RedirectToRoute(SearchRoutes.Results));
        }
Ejemplo n.º 3
0
        public ActionResult SuggestedCandidates(Guid jobAdId, CandidatesPresentationModel presentation)
        {
            // Anyone can see any job ad.

            var jobAd = _jobAdsQuery.GetJobAd <JobAd>(jobAdId);

            if (jobAd == null)
            {
                return(NotFound("job ad", "id", jobAdId));
            }

            // Get the criteria for the search.

            var criteria        = _suggestedMembersQuery.GetCriteria(jobAd);
            var criteriaIsEmpty = criteria.IsEmpty;

            criteria.PrepareCriteria();
            if (criteriaIsEmpty)
            {
                SetDefaults(criteria);
            }

            // Search.

            var model = Search(CurrentEmployer, jobAdId, criteria, presentation, jobAd.Title, jobAd.Status);

            // Save the basis for the search.

            EmployerContext.CurrentCandidates = new SuggestedCandidatesNavigation(jobAdId, jobAd.Title, jobAd.Status, criteria, presentation);
            return(View(model));
        }
Ejemplo n.º 4
0
        protected TListModel Search <TListModel>(IEmployer employer, CandidatesPresentationModel presentation, Func <IEmployer, Range, MemberSearchExecution> search)
            where TListModel : CandidateListModel, new()
        {
            presentation = PreparePresentationModel(presentation);

            // Search.

            var execution = search(employer, presentation.Pagination.ToRange());

            var model = new TListModel
            {
                Criteria     = execution.Criteria,
                Presentation = presentation,
                Results      = new CandidateListResultsModel
                {
                    TotalCandidates     = execution.Results.TotalMatches,
                    CandidateIds        = execution.Results.MemberIds,
                    CandidateStatusHits = GetEnumHitsDictionary(execution.Results.CandidateStatusHits, CandidateStatus.NotLooking),
                    IndustryHits        = execution.Results.IndustryHits,
                    DesiredJobTypeHits  = GetEnumHitsDictionary(execution.Results.DesiredJobTypeHits, JobTypes.All, JobTypes.None),
                },
            };

            // Only get details for those in the range.

            model.Results.Views            = _employerMemberViewsQuery.GetEmployerMemberViews(employer, model.Results.CandidateIds);
            model.Results.LastUpdatedTimes = GetLastUpdatedTimes(model.Results.CandidateIds, model.Results.Views);
            return(model);
        }
Ejemplo n.º 5
0
        public ActionResult PartialFlagList(MemberSearchSortCriteria sortCriteria, CandidatesPresentationModel presentation)
        {
            var model = FlagListResults(sortCriteria, presentation);

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

            EmployerContext.CurrentCandidates = new FlagListNavigation(presentation);
            return(PartialView("CandidateList", model));
        }
Ejemplo n.º 6
0
        public ActionResult Results(bool?createEmailAlert)
        {
            var search = EmployerContext.CurrentSearch;

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

            var presentation = new CandidatesPresentationModel
            {
                DetailLevel = search.DetailLevel == null ? default(DetailLevel) : search.DetailLevel.Value,
                Pagination  = search.Pagination
            };

            var employer = CurrentEmployer;

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

                var searchList = Search(
                    SearchContext.NewSearch,
                    employer,
                    createEmailAlert,
                    search.Criteria,
                    presentation,
                    null);

                // Get suggestions as needed.

                searchList.IsNewSearch    = true;
                searchList.ShowHelpPrompt = ShowHelpPrompt(employer);
                searchList.Recovery       = GetRecovery(searchList);

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

            // Not a new search.

            var model = Search(
                SearchContext.Current,
                employer,
                createEmailAlert,
                search.Criteria,
                PreparePresentationModel(presentation),
                null);

            return(View("Results", model));
        }
Ejemplo n.º 7
0
        public ActionResult PartialSearch(MemberSearchCriteria criteria, CandidatesPresentationModel presentation)
        {
            var employer = CurrentEmployer;

            // Prepare.

            var criteriaIsEmpty = PrepareCriteria(employer, criteria);

            presentation = PreparePresentationModel(presentation);

            if (criteriaIsEmpty)
            {
                // Set up defaults.

                SetDefaults(criteria);
                return(View("CandidateList", CreateEmptyList <SearchListModel>(employer, criteria, presentation)));
            }

            return(PartialView("CandidateList", Search(SearchContext.Filter, employer, null, criteria, presentation, null)));
        }
Ejemplo n.º 8
0
 protected TListModel Search <TListModel>(IEmployer employer, MemberSearchCriteria criteria, CandidatesPresentationModel presentation)
     where TListModel : CandidateListModel, new()
 {
     return(Search <TListModel>(employer, presentation, (e, r) => _executeMemberSearchCommand.Search(e, criteria, r)));
 }
Ejemplo n.º 9
0
        private ManageCandidatesListModel JobAdResults(Guid jobAdId, ApplicantStatus?status, MemberSearchSortCriteria sortCriteria, CandidatesPresentationModel presentation)
        {
            var employer = CurrentEmployer;
            var jobAd    = _jobAdsQuery.GetJobAd <JobAd>(jobAdId);

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

            var searchStatus = status ?? DefaultStatus;
            var model        = Search(employer, jobAdId, searchStatus, sortCriteria, presentation);

            if (model.Results.TotalCandidates == 0 && status == null)
            {
                searchStatus = FallbackStatus;
                model        = Search(employer, jobAdId, searchStatus, sortCriteria, presentation);
            }

            // Indicate those who are rejected.

            model.ApplicantStatus = searchStatus;
            model.Results.RejectedCandidateIds = searchStatus == ApplicantStatus.Rejected ? model.Results.CandidateIds : new List <Guid>();

            var applicantList = _jobAdApplicantsQuery.GetApplicantList(employer, jobAd);
            var counts        = _jobAdApplicantsQuery.GetApplicantCounts(employer, applicantList);

            model.JobAd = new JobAdDataModel
            {
                Id              = jobAdId,
                Title           = jobAd.Title,
                Status          = jobAd.Status,
                ApplicantCounts = new ApplicantCountsModel
                {
                    New         = counts[ApplicantStatus.New],
                    Rejected    = counts[ApplicantStatus.Rejected],
                    ShortListed = counts[ApplicantStatus.Shortlisted],
                },
                Applications = _jobAdApplicantsQuery.GetApplicationsByPositionId(jobAd.Id).ToDictionary(a => a.ApplicantId, a => a),
            };
            model.SortOrders  = new[] { MemberSortOrder.DateUpdated, MemberSortOrder.Flagged, MemberSortOrder.FirstName }.OrderBy(o => o.ToString()).ToArray();
            model.Communities = _communitiesQuery.GetCommunities().ToDictionary(c => c.Id, c => c);
            model.Verticals   = _verticalsQuery.GetVerticals().ToDictionary(v => v.Id, v => v);

            EmployerContext.CurrentSearch     = null;
            EmployerContext.CurrentCandidates = new ManageCandidatesNavigation(jobAdId, model.JobAd.Status, searchStatus, presentation);

            return(model);
        }
Ejemplo n.º 10
0
        protected TListModel CreateEmptyList <TListModel>(IEmployer employer, MemberSearchCriteria criteria, CandidatesPresentationModel presentation)
            where TListModel : CandidateListModel, new()
        {
            var model = new TListModel
            {
                Criteria     = criteria,
                Presentation = presentation,
                Results      = new CandidateListResultsModel
                {
                    TotalCandidates     = 0,
                    CandidateIds        = new List <Guid>(),
                    CandidateStatusHits = GetEnumHitsDictionary(new List <KeyValuePair <CandidateStatus, int> >(), CandidateStatus.NotLooking),
                    IndustryHits        = new List <KeyValuePair <Guid, int> >(),
                    DesiredJobTypeHits  = GetEnumHitsDictionary(new List <KeyValuePair <JobTypes, int> >(), JobTypes.All, JobTypes.None),
                },
            };

            // Only get details for those in the range.

            model.Results.Views            = _employerMemberViewsQuery.GetEmployerMemberViews(employer, model.Results.CandidateIds);
            model.Results.LastUpdatedTimes = GetLastUpdatedTimes(model.Results.CandidateIds, model.Results.Views);
            return(model);
        }
Ejemplo n.º 11
0
 public MemberSearchNavigation(MemberSearchCriteria criteria, CandidatesPresentationModel presentation)
     : base(presentation)
 {
     _criteria = criteria.Clone();
 }
Ejemplo n.º 12
0
 private FolderListModel Search(IEmployer employer, Guid folderId, MemberSearchSortCriteria sortCriteria, CandidatesPresentationModel presentation)
 {
     return(Search <FolderListModel>(employer, presentation, (e, r) => _executeMemberSearchCommand.SearchFolder(e, folderId, sortCriteria, r)));
 }
Ejemplo n.º 13
0
 public FolderNavigation(Guid folderId, CandidatesPresentationModel presentation)
     : base(presentation)
 {
     FolderId = folderId;
 }
Ejemplo n.º 14
0
 public JobAdNavigation(Guid jobAdId, CandidatesPresentationModel presentation)
     : base(presentation)
 {
     JobAdId = jobAdId;
 }
Ejemplo n.º 15
0
 private FlagListListModel Search(IEmployer employer, MemberSearchSortCriteria sortCriteria, CandidatesPresentationModel presentation)
 {
     return(Search <FlagListListModel>(employer, presentation, (e, r) => _executeMemberSearchCommand.SearchFlagged(e, sortCriteria, r)));
 }
Ejemplo n.º 16
0
 public SuggestedCandidatesNavigation(Guid jobAdId, string jobAdTitle, JobAdStatus jobAdStatus, MemberSearchCriteria criteria, CandidatesPresentationModel presentation)
     : base(criteria, presentation)
 {
     JobAdId     = jobAdId;
     JobAdTitle  = jobAdTitle;
     JobAdStatus = jobAdStatus;
 }
Ejemplo n.º 17
0
        private SuggestedCandidatesListModel Search(IEmployer employer, Guid jobAdId, MemberSearchCriteria criteria, CandidatesPresentationModel presentation, string jobAdTitle, JobAdStatus jobAdStatus)
        {
            var searchList = GetSearchList(Search(employer, jobAdId, criteria, presentation));

            searchList.JobAd = new JobAdDataModel
            {
                Id     = jobAdId,
                Title  = jobAdTitle,
                Status = jobAdStatus,
            };

            return(searchList);
        }
Ejemplo n.º 18
0
        public ActionResult Partial(ApplicantStatus status, MemberSearchSortCriteria sortOrder, CandidatesPresentationModel presentation)
        {
            var navigation = (ManageCandidatesNavigation)EmployerContext.CurrentCandidates;

            var model = JobAdResults(navigation.JobAdId, status, sortOrder, presentation);

            if (model == null)
            {
                return(NotFound("job ad", "id", navigation.JobAdId));
            }

            return(PartialView("CandidateList", model));
        }
Ejemplo n.º 19
0
        public ActionResult Manage(Guid jobAdId, ApplicantStatus?status, MemberSearchSortCriteria sortOrder, CandidatesPresentationModel presentation)
        {
            var model = JobAdResults(jobAdId, status, sortOrder, presentation);

            if (model == null)
            {
                return(NotFound("job ad", "id", jobAdId));
            }

            return(View(ManageCandidatesViewName, model));
        }
Ejemplo n.º 20
0
 private ManageCandidatesListModel Search(IEmployer employer, Guid jobAdId, ApplicantStatus status, MemberSearchSortCriteria sortCriteria, CandidatesPresentationModel presentation)
 {
     return(Search <ManageCandidatesListModel>(employer, presentation, (e, r) => _executeMemberSearchCommand.SearchManaged(e, jobAdId, status, sortCriteria, r)));
 }
Ejemplo n.º 21
0
 private SuggestedCandidatesListModel Search(IEmployer employer, Guid jobAdId, MemberSearchCriteria criteria, CandidatesPresentationModel presentation)
 {
     return(Search <SuggestedCandidatesListModel>(employer, presentation, (e, r) => _executeMemberSearchCommand.SearchSuggested(e, jobAdId, criteria, r)));
 }
Ejemplo n.º 22
0
 private BlockListListModel Search(IEmployer employer, Guid blockListId, MemberSearchSortCriteria sortCriteria, CandidatesPresentationModel presentation)
 {
     return(Search <BlockListListModel>(employer, presentation, (e, r) => _executeMemberSearchCommand.SearchBlockList(e, blockListId, sortCriteria, r)));
 }
Ejemplo n.º 23
0
        public ActionResult PartialSuggestedCandidates(MemberSearchCriteria criteria, CandidatesPresentationModel presentation)
        {
            var currentSearch = (SuggestedCandidatesNavigation)EmployerContext.CurrentCandidates;
            var model         = Search(CurrentEmployer, currentSearch.JobAdId, criteria, presentation, currentSearch.JobAdTitle, currentSearch.JobAdStatus);

            EmployerContext.CurrentCandidates = new SuggestedCandidatesNavigation(currentSearch.JobAdId, currentSearch.JobAdTitle, currentSearch.JobAdStatus, criteria, presentation);
            return(PartialView("CandidateList", model));
        }
Ejemplo n.º 24
0
 public ActionResult TemporaryPartialBlockList(MemberSearchSortCriteria sortCriteria, CandidatesPresentationModel presentation)
 {
     return(PartialBlockList(BlockListType.Temporary, sortCriteria, presentation));
 }
Ejemplo n.º 25
0
        private FlagListListModel FlagListResults(MemberSearchSortCriteria sortCriteria, CandidatesPresentationModel presentation)
        {
            var employer = CurrentEmployer;
            var flagList = _candidateFlagListsQuery.GetFlagList(employer);

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

            // Do a search to get the candidates in this flagList.

            var model = Search(employer, sortCriteria, presentation);

            model.FlagList      = flagList;
            model.SortOrders    = SortOrders;
            model.Communities   = _communitiesQuery.GetCommunities().ToDictionary(c => c.Id, c => c);
            model.Verticals     = _verticalsQuery.GetVerticals().ToDictionary(v => v.Id, v => v);
            model.CurrentSearch = EmployerContext.CurrentSearch;
            return(model);
        }
Ejemplo n.º 26
0
 public ActionResult PermanentPartialBlockList(MemberSearchSortCriteria sortCriteria, CandidatesPresentationModel presentation)
 {
     return(PartialBlockList(BlockListType.Permanent, sortCriteria, presentation));
 }
Ejemplo n.º 27
0
        private FolderListModel FolderResults(Guid folderId, MemberSearchSortCriteria sortCriteria, CandidatesPresentationModel presentation)
        {
            var employer = CurrentEmployer;
            var folder   = _candidateFoldersQuery.GetFolder(employer, folderId);

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

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

            var model = Search(employer, folderId, sortCriteria, presentation);

            model.Folder     = folder;
            model.FolderData = new FolderDataModel
            {
                Count     = model.Results.TotalCandidates,
                CanDelete = _candidateFoldersCommand.CanDeleteFolder(employer, folder),
                CanRename = _candidateFoldersCommand.CanRenameFolder(employer, folder),
            };
            model.SortOrders    = SortOrders;
            model.Communities   = _communitiesQuery.GetCommunities().ToDictionary(c => c.Id, c => c);
            model.Verticals     = _verticalsQuery.GetVerticals().ToDictionary(v => v.Id, v => v);
            model.CurrentSearch = EmployerContext.CurrentSearch;

            return(model);
        }
Ejemplo n.º 28
0
        private ActionResult PartialBlockList(BlockListType blockListType, MemberSearchSortCriteria sortCriteria, CandidatesPresentationModel presentation)
        {
            var model = BlockListResults(blockListType, sortCriteria, presentation);

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

            EmployerContext.CurrentCandidates = new BlockListNavigation(blockListType, presentation);
            return(PartialView("CandidateList", model));
        }
Ejemplo n.º 29
0
        public ActionResult Folder(Guid folderId, MemberSearchSortCriteria sortCriteria, CandidatesPresentationModel presentation)
        {
            var model = FolderResults(folderId, sortCriteria, presentation);

            if (model == null)
            {
                return(NotFound("folder", "id", folderId));
            }

            EmployerContext.CurrentCandidates = new FolderNavigation(folderId, presentation);
            return(View(model));
        }
Ejemplo n.º 30
0
        private BlockListListModel BlockListResults(BlockListType blockListType, MemberSearchSortCriteria sortCriteria, CandidatesPresentationModel presentation)
        {
            var employer  = CurrentEmployer;
            var blockList = blockListType == BlockListType.Temporary
                ? _candidateBlockListsQuery.GetTemporaryBlockList(employer)
                : _candidateBlockListsQuery.GetPermanentBlockList(employer);

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

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

            var model = Search(employer, blockList.Id, sortCriteria, presentation);

            model.BlockList     = blockList;
            model.SortOrders    = SortOrders;
            model.Communities   = _communitiesQuery.GetCommunities().ToDictionary(c => c.Id, c => c);
            model.Verticals     = _verticalsQuery.GetVerticals().ToDictionary(v => v.Id, v => v);
            model.CurrentSearch = EmployerContext.CurrentSearch;
            return(model);
        }