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);
        }
Пример #2
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));
        }