private ISearchJobsResponse GetJobSearchResultsResponse(JobSearchResultsFilterModel filterModel)
        {
            if (!this.PageSize.HasValue || this.PageSize.Value <= 0)
            {
                this.PageSize = PageSizeDefaultValue;
            }

            JXTNext_SearchJobsRequest request = JobSearchResultsFilterModel.ProcessInputToSearchRequest(filterModel, this.PageSize, PageSizeDefaultValue);

            string sortingBy = this.Sorting;

            if (filterModel != null && !filterModel.SortBy.IsNullOrEmpty())
            {
                sortingBy = filterModel.SortBy;
            }

            request.SortBy    = JobSearchResultsFilterModel.GetSortEnumFromString(sortingBy);
            ViewBag.SortOrder = JobSearchResultsFilterModel.GetSortStringFromEnum(request.SortBy);

            ISearchJobsResponse        response       = _BLConnector.SearchJobs(request);
            JXTNext_SearchJobsResponse jobResultsList = response as JXTNext_SearchJobsResponse;


            ViewBag.Request     = JsonConvert.SerializeObject(filterModel);
            ViewBag.FilterModel = JsonConvert.SerializeObject(filterModel);
            ViewBag.PageSize    = (int)this.PageSize;
            ViewBag.CssClass    = this.CssClass;
            if (jobResultsList != null)
            {
                ViewBag.TotalCount = jobResultsList.Total;
            }

            ViewBag.JobResultsPageUrl = SfPageHelper.GetPageUrlById(ResultsPageId.IsNullOrWhitespace() ? Guid.Empty : new Guid(ResultsPageId));
            ViewBag.CurrentPageUrl    = SfPageHelper.GetPageUrlById(SiteMapBase.GetActualCurrentNode().Id);
            ViewBag.JobDetailsPageUrl = SfPageHelper.GetPageUrlById(DetailsPageId.IsNullOrWhitespace() ? Guid.Empty : new Guid(DetailsPageId));
            ViewBag.EmailJobPageUrl   = SfPageHelper.GetPageUrlById(EmailJobPageId.IsNullOrWhitespace() ? Guid.Empty : new Guid(EmailJobPageId));
            ViewBag.HidePushStateUrl  = this.HidePushStateUrl;
            ViewBag.PageFullUrl       = SfPageHelper.GetPageUrlById(SiteMapBase.GetActualCurrentNode().Id);
            ViewBag.IsMember          = SitefinityHelper.IsUserLoggedIn("Member");

            var currentIdentity = ClaimsManager.GetCurrentIdentity();

            if (currentIdentity.IsAuthenticated)
            {
                var currUser = SitefinityHelper.GetUserById(currentIdentity.UserId);
                if (currUser != null)
                {
                    ViewBag.Email = currUser.Email;
                }
            }

            return(response);
        }
        // GET: JobSearchResults
        public ActionResult Index([ModelBinder(typeof(JobSearchResultsFilterBinder))] JobSearchResultsFilterModel filterModel, int?jobId)
        {
            dynamic dynamicJobResultsList = null;

            if (filterModel != null && !string.IsNullOrEmpty(filterModel.Keywords))
            {
                filterModel.Keywords = filterModel.Keywords.Trim();
                //filterModel.Keywords = filterModel.Keywords.Trim(charsToTrim);
            }

            if (jobId.HasValue)
            {
                IGetJobListingRequest jobListingRequest = new JXTNext_GetJobListingRequest {
                    JobID = jobId.Value
                };
                IGetJobListingResponse jobListingResponse = _BLConnector.GuestGetJob(jobListingRequest);
                var jobDetails = jobListingResponse.Job;
                var classificationTopLevelId = jobListingResponse.Job.CustomData["Classifications[0].Filters[0].ExternalReference"];

                JobSearchResultsFilterModel filterModelNew = new JobSearchResultsFilterModel()
                {
                    Filters = new List <JobSearchFilterReceiver>()
                };
                JobSearchFilterReceiverItem filterReceiverItem = new JobSearchFilterReceiverItem()
                {
                    ItemID = classificationTopLevelId
                };
                JobSearchFilterReceiver filterReceiver = new JobSearchFilterReceiver()
                {
                    rootId = "Classifications", values = new List <JobSearchFilterReceiverItem>()
                };
                filterReceiver.values.Add(filterReceiverItem);
                filterModelNew.Filters.Add(filterReceiver);

                ISearchJobsResponse        response       = GetJobSearchResultsResponse(filterModelNew);
                JXTNext_SearchJobsResponse jobResultsList = response as JXTNext_SearchJobsResponse;
                jobResultsList.SearchResults.RemoveAll(item => item.JobID == jobId.Value);
                dynamicJobResultsList = jobResultsList as dynamic;
            }
            else if (filterModel != null)
            {
                filterModel = _processWidgetConfiguredFilter(filterModel);
                ISearchJobsResponse response = GetJobSearchResultsResponse(filterModel);
                dynamicJobResultsList = response as dynamic;
            }

            return(View(this.TemplateName, dynamicJobResultsList));
        }
예제 #3
0
        private List <JobFilterRoot> GetJobSearchResultsFilters(JobSearchResultsFilterModel filterModel)
        {
            JXTNext_SearchJobsRequest request = JobSearchResultsFilterModel.ProcessInputToSearchRequest(filterModel, 10);

            request.SortBy = JobSearchResultsFilterModel.GetSortEnumFromString(filterModel.SortBy);
            ISearchJobsResponse        response       = _BLConnector.SearchJobs(request);
            JXTNext_SearchJobsResponse jobResultsList = response as JXTNext_SearchJobsResponse;

            if (jobResultsList != null)
            {
                return(jobResultsList.SearchResultsFilters);
            }
            else
            {
                return(null);
            }
        }
        public ActionResult Details(UserProfile user)
        {
            dynamic dynamicJobResultsList = null;

            JobSearchResultsFilterModel filterModelNew = new JobSearchResultsFilterModel()
            {
                ConsultantSearch = new Consultant()
                {
                    Email = user.User.Email
                }
            };
            ISearchJobsResponse        response       = GetJobSearchResultsResponse(filterModelNew);
            JXTNext_SearchJobsResponse jobResultsList = response as JXTNext_SearchJobsResponse;

            dynamicJobResultsList = jobResultsList as dynamic;

            return(this.View(this.TemplateName, dynamicJobResultsList));
        }
예제 #5
0
        public List <JobViewModel> GetListViewModel()
        {
            var vmList = new List <JobViewModel>();

            ISearchJobsRequest jobListingRequest = new JXTNext_SearchJobsRequest {
                PageSize = 10
            };
            JXTNext_SearchJobsResponse jobListingResponse = (JXTNext_SearchJobsResponse)_jxtBLConnector.SearchJobs(jobListingRequest);

            if (jobListingResponse.Success)
            {
                foreach (var jl in jobListingResponse.SearchResults)
                {
                    vmList.Add(this.GetVM(jl));
                }
            }

            return(vmList);
        }
예제 #6
0
        public ActionResult Details(Telerik.Sitefinity.DynamicModules.Model.DynamicContent item)
        {
            dynamic dynamicJobResultsList = null;
            string  location = string.Empty;
            Dictionary <string, List <string> > locationDict = new Dictionary <string, List <string> >();

            if (!string.IsNullOrWhiteSpace(Request.QueryString["location"]))
            {
                location = Request.QueryString["location"];
                string[] locArr = location.Split(',');

                for (int i = 0; i < locArr.Length; i++)
                {
                    var locationDetails = GetLocationGuid(locArr[i].Trim(new char[] { ' ' }));
                    if (locationDetails.Key != null)
                    {
                        if (locationDict.ContainsKey(locationDetails.Key))
                        {
                            locationDict[locationDetails.Key].Add(locationDetails.Value);
                        }
                        else
                        {
                            locationDict[locationDetails.Key] = new List <string>();
                            locationDict[locationDetails.Key].Add(locationDetails.Value);
                        }
                    }
                }
            }

            JXTNext_SearchJobsRequest   request        = new JXTNext_SearchJobsRequest();
            JobSearchResultsFilterModel filterModelNew = new JobSearchResultsFilterModel();

            if (item.DoesFieldExist("ConsultantName"))
            {
                string consultantFullName = item.GetString("ConsultantName");

                if (!string.IsNullOrEmpty(consultantFullName))
                {
                    ViewBag.ConsultantName = consultantFullName;
                    List <string> consultantNameList = consultantFullName.Split(new char[] { ' ' }).ToList();
                    filterModelNew.ConsultantSearch           = new Consultant();
                    filterModelNew.ConsultantSearch.Email     = null;
                    filterModelNew.ConsultantSearch.FirstName = consultantNameList.First();
                    if (consultantNameList.Count > 1)
                    {
                        filterModelNew.ConsultantSearch.LastName = consultantNameList.Last();
                    }

                    if (!this.PageSize.HasValue || this.PageSize.Value <= 0)
                    {
                        this.PageSize = PageSizeDefaultValue;
                    }

                    request = JobSearchResultsFilterModel.ProcessInputToSearchRequest(filterModelNew, this.PageSize, PageSizeDefaultValue);

                    string sortingBy = this.Sorting;
                    if (filterModelNew != null && !filterModelNew.SortBy.IsNullOrEmpty())
                    {
                        sortingBy = filterModelNew.SortBy;
                    }

                    request.SortBy    = JobSearchResultsFilterModel.GetSortEnumFromString(sortingBy);
                    ViewBag.SortOrder = JobSearchResultsFilterModel.GetSortStringFromEnum(request.SortBy);
                    Log.Write($"Job Search by Consultant name request json : " + JsonConvert.SerializeObject(request), ConfigurationPolicy.ErrorLog);
                    ISearchJobsResponse        response       = _BLConnector.SearchJobs(request);
                    JXTNext_SearchJobsResponse jobResultsList = response as JXTNext_SearchJobsResponse;
                    dynamicJobResultsList = jobResultsList as dynamic;
                }
            }
            else if (item.DoesFieldExist("Email"))
            {
                var email = item.GetString("Email");
                if (!string.IsNullOrEmpty(email))
                {
                    filterModelNew = new JobSearchResultsFilterModel()
                    {
                        ConsultantSearch = new Consultant()
                        {
                            Email = email
                        }
                    };

                    if (!this.PageSize.HasValue || this.PageSize.Value <= 0)
                    {
                        this.PageSize = PageSizeDefaultValue;
                    }

                    request = JobSearchResultsFilterModel.ProcessInputToSearchRequest(filterModelNew, this.PageSize, PageSizeDefaultValue);

                    string sortingBy = this.Sorting;
                    if (filterModelNew != null && !filterModelNew.SortBy.IsNullOrEmpty())
                    {
                        sortingBy = filterModelNew.SortBy;
                    }

                    request.SortBy    = JobSearchResultsFilterModel.GetSortEnumFromString(sortingBy);
                    ViewBag.SortOrder = JobSearchResultsFilterModel.GetSortStringFromEnum(request.SortBy);
                    Log.Write($"Job Search by Consultant Email request json : " + JsonConvert.SerializeObject(request), ConfigurationPolicy.ErrorLog);
                    ISearchJobsResponse        response       = _BLConnector.SearchJobs(request);
                    JXTNext_SearchJobsResponse jobResultsList = response as JXTNext_SearchJobsResponse;
                    dynamicJobResultsList = jobResultsList as dynamic;
                }
            }

            filterModelNew.ConsultantSearch = null;
            filterModelNew.Filters          = new List <JobSearchFilterReceiver>();

            if (dynamicJobResultsList.Total == 0)
            {
                if (item.DoesFieldExist("Category"))
                {
                    JobSearchFilterReceiver classificationSearch = new JobSearchFilterReceiver();
                    classificationSearch.rootId       = "Classifications";
                    classificationSearch.searchTarget = "Categories";
                    classificationSearch.values       = new List <JobSearchFilterReceiverItem>();
                    TrackedList <Guid> classIds = (TrackedList <Guid>)item.GetValue("Category");
                    if (classIds != null && classIds.Count > 0)
                    {
                        foreach (var id in classIds)
                        {
                            JobSearchFilterReceiverItem filterItem = new JobSearchFilterReceiverItem();
                            filterItem.ItemID     = id.ToString().ToUpper();
                            filterItem.SubTargets = null;
                            classificationSearch.values.Add(filterItem);
                        }
                    }

                    filterModelNew.Filters.Add(classificationSearch);
                }

                if (locationDict.Count > 0)
                {
                    JobSearchFilterReceiver locationSearch = new JobSearchFilterReceiver();
                    locationSearch.rootId       = "CountryLocationArea";
                    locationSearch.searchTarget = "Categories";
                    locationSearch.values       = new List <JobSearchFilterReceiverItem>();
                    foreach (var cnsltLocation in locationDict)
                    {
                        JobSearchFilterReceiverItem filterItem = new JobSearchFilterReceiverItem();
                        filterItem.ItemID     = cnsltLocation.Key.ToString().ToUpper();
                        filterItem.SubTargets = new List <JobSearchFilterReceiverItem>();
                        var subLocations = cnsltLocation.Value;
                        foreach (string subLocation in subLocations)
                        {
                            JobSearchFilterReceiverItem jobSearchFilterReceiverItem = new JobSearchFilterReceiverItem();
                            jobSearchFilterReceiverItem.ItemID     = subLocation;
                            jobSearchFilterReceiverItem.SubTargets = null;
                            filterItem.SubTargets.Add(jobSearchFilterReceiverItem);
                        }
                        locationSearch.values.Add(filterItem);
                    }
                    filterModelNew.Filters.Add(locationSearch);
                }


                request = JobSearchResultsFilterModel.ProcessInputToSearchRequest(filterModelNew, this.PageSize, PageSizeDefaultValue);

                string sortBy = this.Sorting;
                if (filterModelNew != null && !filterModelNew.SortBy.IsNullOrEmpty())
                {
                    sortBy = filterModelNew.SortBy;
                }

                request.SortBy    = JobSearchResultsFilterModel.GetSortEnumFromString(sortBy);
                ViewBag.SortOrder = JobSearchResultsFilterModel.GetSortStringFromEnum(request.SortBy);
                Log.Write($"Job Search by Consultant related classification and location request json : " + JsonConvert.SerializeObject(request), ConfigurationPolicy.ErrorLog);
                ISearchJobsResponse        searchResponse        = _BLConnector.SearchJobs(request);
                JXTNext_SearchJobsResponse relatedJobResultsList = searchResponse as JXTNext_SearchJobsResponse;
                dynamicJobResultsList = relatedJobResultsList as dynamic;
            }


            ViewBag.PageSize          = (int)this.PageSize;
            ViewBag.CssClass          = this.CssClass;
            ViewBag.JobResultsPageUrl = SfPageHelper.GetPageUrlById(ResultsPageId.IsNullOrWhitespace() ? Guid.Empty : new Guid(ResultsPageId));
            ViewBag.CurrentPageUrl    = SfPageHelper.GetPageUrlById(SiteMapBase.GetActualCurrentNode().Id);
            ViewBag.JobDetailsPageUrl = SfPageHelper.GetPageUrlById(DetailsPageId.IsNullOrWhitespace() ? Guid.Empty : new Guid(DetailsPageId));

            return(this.View(this.templateNamePrefix + this.TemplateName, dynamicJobResultsList));
        }
        public JsonResult GetSearchResults_WithLeftFiltersSelected(string jobRequest, int pageNumber, string sortBy)
        {
            //Use preconfigured search config from widget settings if available
            JobSearchResultsFilterModel searchInputs;



            if (SearchConfig != null)
            {
                searchInputs = JsonConvert.DeserializeObject <JobSearchResultsFilterModel>(SearchConfig);
            }
            else
            {
                searchInputs = JsonConvert.DeserializeObject <JobSearchResultsFilterModel>(jobRequest);
            }

            if (this.UseConfigFilters)
            {
                var jobFilterComponents = this.SerializedJobSearchParams == null ? null : JsonConvert.DeserializeObject <List <JobSearchModel> >(this.SerializedJobSearchParams);

                if (jobFilterComponents != null)
                {
                    searchInputs = new JobSearchResultsFilterModel()
                    {
                        Keywords = this.KeywordsSelectedJobs, Filters = new List <JobSearchFilterReceiver>()
                    };
                    foreach (JobSearchModel item in jobFilterComponents)
                    {
                        FilterData(item.Filters);
                        item.Filters = item.Filters.Where(d => d.Show == true || d.Filters?.Count > 0).ToList();
                    }

                    foreach (var configItem in jobFilterComponents)
                    {
                        var rootFilterItem = new JobSearchFilterReceiver()
                        {
                            values = new List <JobSearchFilterReceiverItem>()
                        };
                        rootFilterItem.rootId = configItem.FilterType;

                        foreach (var subFilItem in configItem.Filters)
                        {
                            var targetFilterItem = new JobSearchFilterReceiverItem()
                            {
                                SubTargets = new List <JobSearchFilterReceiverItem>()
                            };
                            ProcessConfigFilterItems(targetFilterItem, subFilItem);
                            rootFilterItem.values.Add(targetFilterItem);
                        }

                        searchInputs.Filters.Add(rootFilterItem);
                    }
                }
            }

            searchInputs.Page   = pageNumber;
            searchInputs.SortBy = sortBy;

            if (!this.PageSize.HasValue || this.PageSize.Value <= 0)
            {
                this.PageSize = PageSizeDefaultValue;
            }

            JXTNext_SearchJobsRequest searchRequest = JobSearchResultsFilterModel.ProcessInputToSearchRequest(searchInputs, this.PageSize, PageSizeDefaultValue);


            #region Filter Logic

            List <string> selectedFilterID = new List <string>();
            List <JobSearchFilterReceiver> selectedFilters = searchInputs.Filters;
            if (selectedFilters != null)
            {
                foreach (var filter in selectedFilters)
                {
                    if (filter != null)
                    {
                        foreach (var value in filter.values)
                        {
                            if (value != null)
                            {
                                selectedFilterID.Add(value.ItemID);
                                if (value.SubTargets != null)
                                {
                                    foreach (var subTarget in value.SubTargets)
                                    {
                                        selectedFilterID.Add(value.ItemID + "_" + subTarget.ItemID);
                                    }
                                }
                            }
                        }
                    }
                }
            }



            #endregion


            string sortingBy = this.Sorting;
            if (searchInputs != null && !searchInputs.SortBy.IsNullOrEmpty())
            {
                sortingBy = searchInputs.SortBy;
            }

            searchRequest.SortBy = JobSearchResultsFilterModel.GetSortEnumFromString(sortingBy);
            ViewBag.SortOrder    = JobSearchResultsFilterModel.GetSortStringFromEnum(searchRequest.SortBy);

            JXTNext_SearchJobsResponse jobResponse = (JXTNext_SearchJobsResponse)_BLConnector.SearchJobs(searchRequest);

            foreach (var item in jobResponse.SearchResults)
            {
                List <OrderedDictionary> classificationItemsList = new List <OrderedDictionary>();
                item.ClassificationsRootName = "Classifications";

                // Assuming the maximum ten parents the job will be posted
                for (int i = 0; i < 10; i++)
                {
                    string key   = "Classifications[0].Filters[" + i + "].ExternalReference";
                    string value = "Classifications[0].Filters[" + i + "].Value";
                    string parentClassificationsKey = "Classifications[0].Filters[" + i + "].SubLevel[0]";
                    if (item.CustomData.ContainsKey(key))
                    {
                        OrderedDictionary classifOrdDict = new OrderedDictionary();
                        classifOrdDict.Add(item.CustomData[key], item.CustomData[value]);
                        JobDetailsViewModel.ProcessCustomData(parentClassificationsKey, item.CustomData, classifOrdDict);
                        OrderedDictionary classifParentIdsOrdDict = new OrderedDictionary();
                        JobDetailsViewModel.AppendParentIds(classifOrdDict, classifParentIdsOrdDict);
                        classificationItemsList.Add(classifParentIdsOrdDict);
                        item.Classifications = classificationItemsList;
                    }
                }

                // Take the first item in the list as SEO route for Job Details page
                if (item.ClassificationURL != null)
                {
                    item.ClassificationsSEORouteName = item.ClassificationURL;
                }
                else if (item.Classifications.Count > 0)
                {
                    List <string> seoString = new List <string>();
                    foreach (var key in item.Classifications[0].Keys)
                    {
                        string value     = item.Classifications[0][key].ToString();
                        string SEOString = Regex.Replace(value, @"([^\w]+)", "-");
                        seoString.Add(SEOString + "-jobs");
                    }
                    seoString.Add(Regex.Replace(item.Title + "-job", @"([^\w]+)", "-"));

                    item.ClassificationsSEORouteName = String.Join("/", seoString);
                }
            }

            jobResponse.SelectedFilters = selectedFilterID;

            return(new JsonResult {
                Data = jobResponse
            });
        }