// GET: JobSearch
        public ActionResult Index()
        {
            // This is the CSS classes enter from More Options
            // this needs to me moved to a viewmodel rather than ViewData
            ViewData["CssClass"]              = this.CssClass;
            ViewData["JobResultsPageUrl"]     = SfPageHelper.GetPageUrlById(ResultsPageId.IsNullOrWhitespace() ? Guid.Empty : new Guid(ResultsPageId));
            ViewData["AdvancedSearchPageUrl"] = AdvancedSearchPageId != Guid.Empty ? SfPageHelper.GetPageUrlById(AdvancedSearchPageId) : "/advancedsearch";

            var jobSearchComponents = this.SerializedJobSearchParams == null ? null : JsonConvert.DeserializeObject <List <JobSearchModel> >(this.SerializedJobSearchParams);

            if (jobSearchComponents != null)
            {
                foreach (JobSearchModel item in jobSearchComponents)
                {
                    FilterData(item.Filters);
                    item.Filters = item.Filters.Where(d => d.Show == true || d.Filters?.Count > 0).ToList();
                }
            }

            var fullTemplateName = this.templateNamePrefix + this.TemplateName;

            AppendParentIds(jobSearchComponents);
            ViewData["PrefixIdsText"] = this.PrefixIdText == null?"":this.PrefixIdText;

            return(View(fullTemplateName, jobSearchComponents));
        }
        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);
        }
Beispiel #3
0
        // GET: JobDetails
        public ActionResult Index(int?jobId)
        {
            JobDetailsViewModel viewModel = new JobDetailsViewModel();

            if (jobId.HasValue)
            {
                // Get job source or url referral

                string UrlReferral = string.Empty;
                if (!string.IsNullOrWhiteSpace(Request.QueryString["source"]))
                {
                    UrlReferral = Request.QueryString["source"];
                }
                else
                {
                    UrlReferral = this.GetCookieDomain(Request.Cookies["JobsViewed"], jobId.Value);
                }

                viewModel.UrlReferral = UrlReferral;
                Log.Write($" viewModel.UrlReferral  : " + viewModel.UrlReferral, ConfigurationPolicy.ErrorLog);

                IGetJobListingRequest jobListingRequest = new JXTNext_GetJobListingRequest {
                    JobID = jobId.Value
                };
                IGetJobListingResponse jobListingResponse = _BLConnector.GuestGetJob(jobListingRequest);

                if (jobListingResponse.Job != null && !jobListingResponse.Job.IsDeleted)
                {
                    viewModel.JobDetails = jobListingResponse.Job;

                    // Getting Consultant Avatar Image Url from Sitefinity
                    viewModel.ApplicationEmail = jobListingResponse.Job.CustomData["ApplicationMethod.ApplicationEmail"];
                    var user = SitefinityHelper.GetUserByEmail(jobListingResponse.Job.CustomData["ApplicationMethod.ApplicationEmail"]);
                    if (user != null && user.Id != Guid.Empty)
                    {
                        viewModel.ApplicationAvatarImageUrl = SitefinityHelper.GetUserAvatarUrlById(user.Id);
                    }

                    if (this.Model.IsJobApplyAvailable())
                    {
                        viewModel.JobApplyAvailable = true;
                    }

                    // Processing Classifications
                    OrderedDictionary classifOrdDict = new OrderedDictionary();
                    classifOrdDict.Add(jobListingResponse.Job.CustomData["Classifications[0].Filters[0].ExternalReference"], jobListingResponse.Job.CustomData["Classifications[0].Filters[0].Value"]);
                    string parentClassificationsKey = "Classifications[0].Filters[0].SubLevel[0]";
                    JobDetailsViewModel.ProcessCustomData(parentClassificationsKey, jobListingResponse.Job.CustomData, classifOrdDict);
                    OrderedDictionary classifParentIdsOrdDict = new OrderedDictionary();
                    JobDetailsViewModel.AppendParentIds(classifOrdDict, classifParentIdsOrdDict);

                    var bull = jobListingResponse.Job.CustomData["Bulletpoints.BulletPoint1"];

                    // Processing Locations
                    OrderedDictionary locOrdDict = new OrderedDictionary();
                    locOrdDict.Add(jobListingResponse.Job.CustomData["CountryLocationArea[0].Filters[0].ExternalReference"], jobListingResponse.Job.CustomData["CountryLocationArea[0].Filters[0].Value"]);
                    string parentLocKey = "CountryLocationArea[0].Filters[0].SubLevel[0]";
                    JobDetailsViewModel.ProcessCustomData(parentLocKey, jobListingResponse.Job.CustomData, locOrdDict);
                    OrderedDictionary locParentIdsOrdDict = new OrderedDictionary();
                    JobDetailsViewModel.AppendParentIds(locOrdDict, locParentIdsOrdDict);

                    DateTime localTime = TimeZoneInfo.ConvertTimeFromUtc(ConversionHelper.GetDateTimeFromUnix(jobListingResponse.Job.DateCreated), TimeZoneInfo.FindSystemTimeZoneById("AUS Eastern Standard Time"));
                    DateTime utcTime   = ConversionHelper.GetDateTimeFromUnix(jobListingResponse.Job.DateCreated);
                    DateTime elocalTime;
                    DateTime eutcTime = new DateTime();
                    TimeSpan offset   = localTime - utcTime;
                    TimeSpan eoffset  = new TimeSpan();


                    if (jobListingResponse.Job.ExpiryDate.HasValue)
                    {
                        elocalTime = TimeZoneInfo.ConvertTimeFromUtc(ConversionHelper.GetDateTimeFromUnix(jobListingResponse.Job.ExpiryDate.Value), TimeZoneInfo.FindSystemTimeZoneById("AUS Eastern Standard Time"));
                        eutcTime   = ConversionHelper.GetDateTimeFromUnix(jobListingResponse.Job.ExpiryDate.Value);
                        eoffset    = elocalTime - eutcTime;
                    }

                    viewModel.Classifications         = classifParentIdsOrdDict;
                    viewModel.Locations               = locParentIdsOrdDict;
                    viewModel.ClassificationsRootName = "Classifications";
                    viewModel.LocationsRootName       = "CountryLocationArea";
                    var siteSettingsHelper = new SiteSettingsHelper();
                    viewModel.JobCurrencySymbol = siteSettingsHelper.GetJobCurrencySymbol();

                    // Getting the SEO route name for classifications
                    List <string> seoString = new List <string>();
                    foreach (var key in classifParentIdsOrdDict.Keys)
                    {
                        string value     = classifParentIdsOrdDict[key].ToString();
                        string SEOString = Regex.Replace(value, @"([^\w]+)", "-");
                        seoString.Add(SEOString);
                    }

                    viewModel.ClassificationsSEORouteName = jobListingResponse.Job.ClassificationURL;

                    ViewBag.CssClass = this.CssClass;
                    ViewBag.JobApplicationPageUrl = SfPageHelper.GetPageUrlById(JobApplicationPageId.IsNullOrWhitespace() ? Guid.Empty : new Guid(JobApplicationPageId));
                    ViewBag.JobResultsPageUrl     = SfPageHelper.GetPageUrlById(JobResultsPageId.IsNullOrWhitespace() ? Guid.Empty : new Guid(JobResultsPageId));
                    ViewBag.EmailJobPageUrl       = SfPageHelper.GetPageUrlById(EmailJobPageId.IsNullOrWhitespace() ? Guid.Empty : new Guid(EmailJobPageId));
                    ViewBag.GoogleForJobs         = ReplaceToken(GoogleForJobsTemplate, JsonConvert.SerializeObject(new
                    {
                        CurrencySymbol        = "$",
                        SalaryLowerBand       = jobListingResponse.Job.CustomData.ContainsKey("Salaries[0].Filters[0].Min") ? jobListingResponse.Job.CustomData["Salaries[0].Filters[0].Min"] : null,
                        SalaryUpperBand       = jobListingResponse.Job.CustomData.ContainsKey("Salaries[0].Filters[0].Max") ? jobListingResponse.Job.CustomData["Salaries[0].Filters[0].Max"] : null,
                        FullDescription       = jobListingResponse.Job.Description,
                        Description           = jobListingResponse.Job.ShortDescription,
                        AdvertiserCompanyName = jobListingResponse.Job.CustomData.ContainsKey("CompanyName") ? jobListingResponse.Job.CustomData["CompanyName"] : null,
                        ProfessionName        = jobListingResponse.Job.CustomData.ContainsKey("Classifications[0].Filters[0].Value") ? jobListingResponse.Job.CustomData["Classifications[0].Filters[0].Value"] : null,
                        LocationName          = jobListingResponse.Job.CustomData.ContainsKey("CountryLocationArea[0].Filters[0].Value") ? jobListingResponse.Job.CustomData["CountryLocationArea[0].Filters[0].Value"] : null,
                        AreaName   = jobListingResponse.Job.CustomData.ContainsKey("CountryLocationArea[0].Filters[0].SubLevel[0].Value") ? jobListingResponse.Job.CustomData["CountryLocationArea[0].Filters[0].SubLevel[0].Value"] : null,
                        JobName    = jobListingResponse.Job.Title,
                        DatePosted = string.Format("|{0}+{1}|", utcTime.ToString("yyyy-MM-ddThh:mm:ss"), offset.Hours.ToString("00") + ":" + offset.Minutes.ToString("00")),
                        ExpiryDate = (jobListingResponse.Job.ExpiryDate.HasValue) ? string.Format("|{0}+{1}|", eutcTime.ToString("yyyy-MM-ddThh:mm:ss"), eoffset.Hours.ToString("00") + ":" + eoffset.Minutes.ToString("00")) : string.Empty,
                        Address    = jobListingResponse.Job.Address
                    }));
                    var fullTemplateName = this.templateNamePrefix + this.TemplateName;
                    // If it is null make sure that pass empty string , because html attrubutes will not work properly.
                    viewModel.JobDetails.Address           = viewModel.JobDetails.Address == null ? "" : viewModel.JobDetails.Address;
                    viewModel.JobDetails.AddressLatitude   = viewModel.JobDetails.AddressLatitude == null ? "" : viewModel.JobDetails.AddressLatitude;
                    viewModel.JobDetails.AddressLongtitude = viewModel.JobDetails.AddressLongtitude == null ? "" : viewModel.JobDetails.AddressLongtitude;

                    #region Check job already applied
                    ViewBag.IsJobApplied = false;
                    JXTNext_MemberAppliedJobResponse response = _BLConnector.MemberAppliedJobsGet() as JXTNext_MemberAppliedJobResponse;
                    if (response.Success)
                    {
                        foreach (var item in response.MemberAppliedJobs)
                        {
                            if (item.JobId == jobId.Value)
                            {
                                ViewBag.IsJobApplied = true;
                                break;
                            }
                        }
                    }
                    #endregion
                    var meta = new System.Web.UI.HtmlControls.HtmlMeta();
                    meta.Attributes.Add("property", "og:title");
                    meta.Content = jobListingResponse.Job.Title;

                    // Get the current page handler in order to access the page header
                    var pageHandler = this.HttpContext.CurrentHandler.GetPageHandler();
                    pageHandler.Header.Controls.Add(meta);
                    return(View(fullTemplateName, viewModel));
                }
                else
                {
                    if (jobListingResponse.Job != null && jobListingResponse.Job.IsDeleted)
                    {
                        return(Content("This Job is no longer available!"));
                    }
                    else
                    {
                        return(Content("No job has been found"));
                    }
                }
            }

            return(Content("No job has been selected"));
        }
        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));
        }