Exemple #1
0
 private static int GetJobCount(LocationReference location)
 {
     switch (location.ToString())
     {
     default:
         return(1);
     }
 }
Exemple #2
0
        public JobRegion Map(LocationReference location)
        {
            var l    = _world.GetPointSet(location);
            var id   = _mappings.First(x => l.IsSubsetOf(x.Key)).Value;
            var name = location.ToString();

            return(new JobRegion {
                id = id, name = name
            });
        }
Exemple #3
0
        public ActionResult ClosestLocation(int?countryId, float latitude, float longitude)
        {
            try
            {
                // If the country is not specified then use the current context.

                var country = countryId == null ? ActivityContext.Location.Country : _locationQuery.GetCountry(countryId.Value);

                // Get the closest locality.

                var locality = _locationQuery.GetClosestLocality(country, new GeoCoordinates(latitude, longitude));
                if (locality == null)
                {
                    return(ResolveLocation(countryId, null));
                }

                // Return the first postal suburb in the first postal code.

                LocationReference locationReference;

                var postalCodes = _locationQuery.GetPostalCodes(locality).OrderBy(pc => pc.Postcode).ToList();
                if (postalCodes.Count == 0)
                {
                    locationReference = new LocationReference(locality);
                    return(ResolveLocation(locationReference.ToString(), locationReference.ToString()));
                }

                var postalSuburbs = _locationQuery.GetPostalSuburbs(postalCodes[0]).OrderBy(ps => ps.Name).ToList();
                if (postalSuburbs.Count == 0)
                {
                    locationReference = new LocationReference(postalCodes[0]);
                    return(ResolveLocation(locationReference.ToString(), locationReference.ToString()));
                }

                locationReference = new LocationReference(postalSuburbs[0]);
                return(ResolveLocation(locationReference.ToString(), locationReference.ToString()));
            }
            catch (Exception)
            {
                return(ResolveLocation(countryId, null));
            }
        }
        public static string GetUrlSegment(this LocationReference locationReference, string suffix)
        {
            if (locationReference == null)
            {
                return("-");
            }

            var location = locationReference.IsCountry
                ? locationReference.Country.ToString()
                : locationReference.ToString();

            location = location.EncodeUrlSegment();
            return(string.IsNullOrEmpty(location) ? "-" : location + GetSuffix(suffix));
        }
Exemple #5
0
        protected ReadOnlyUrl GetJobUrl(Guid jobAdId, string jobAdTitle, LocationReference location, IList <Industry> industries)
        {
            var sb = new StringBuilder();

            // Location.

            if (location == null)
            {
                sb.Append("-");
            }
            else
            {
                sb.Append(!string.IsNullOrEmpty(location.ToString())
                    ? TextUtil.StripExtraWhiteSpace(TextUtil.StripToAlphaNumericAndWhiteSpace(location.ToString())).ToLower().Replace(' ', '-')
                    : location.Country.Name.ToLower());
            }

            // Industry. If there is only one industry then use it.  Do not concatenate more as this can easily lead to
            // urls being longer then url or segment lengths.

            var industrySb = new StringBuilder();

            if (industries != null && industries.Count > 0)
            {
                industrySb.Append(industries[0].UrlName);
            }
            sb.Append("/");
            if (industrySb.Length == 0)
            {
                sb.Append("-");
            }
            else
            {
                sb.Append(industrySb);
            }

            // Job title.

            sb.Append("/");
            sb.Append(TextUtil.StripExtraWhiteSpace(TextUtil.StripToAlphaNumericAndSpace(jobAdTitle)).ToLower().Replace(' ', '-'));

            // Id

            sb.Append("/");
            sb.Append(jobAdId.ToString());

            return(new ReadOnlyApplicationUrl(_baseJobUrl, sb.ToString()));
        }
Exemple #6
0
        private ReadOnlyUrl GetJobUrl(Guid jobAdId, string jobAdTitle, LocationReference location, string industry)
        {
            var sb = new StringBuilder();

            // Location.

            sb.Append(!string.IsNullOrEmpty(location.ToString())
                ? TextUtil.StripExtraWhiteSpace(TextUtil.StripToAlphaNumericAndWhiteSpace(location.ToString())).ToLower().Replace(' ', '-')
                : "-");

            // Industry. If there is only one industry then use it.  Do not concatenate more as this can easily lead to
            // urls being longer then url or segment lengths.

            var industrySb = new StringBuilder();

            if (industry != null)
            {
                industrySb.Append(industry);
            }
            sb.Append("/");
            if (industrySb.Length == 0)
            {
                sb.Append("-");
            }
            else
            {
                sb.Append(industrySb);
            }

            // Job title.

            sb.Append("/");
            var segment = TextUtil.StripExtraWhiteSpace(TextUtil.StripToAlphaNumericAndSpace(jobAdTitle)).ToLower().Replace(' ', '-');

            if (segment.Length > MaxTitleSegmentLength)
            {
                segment = segment.Substring(0, MaxTitleSegmentLength);
            }
            sb.Append(segment);

            // Id

            sb.Append("/");
            sb.Append(jobAdId.ToString());

            return(new ReadOnlyApplicationUrl(_baseJobUrl, sb.ToString()));
        }
Exemple #7
0
 private static void AssertLocation(HtmlNode node, LocationReference location)
 {
     Assert.IsNotNull(node);
     if (location.IsCountry)
     {
         Assert.AreEqual(1, node.ChildNodes.Count);
         Assert.AreEqual(HtmlNodeType.Text, node.ChildNodes[0].NodeType);
         Assert.AreEqual(location.Country.ToString(), node.ChildNodes[0].InnerText.Trim());
     }
     else
     {
         Assert.AreEqual(3, node.ChildNodes.Count);
         Assert.AreEqual(HtmlNodeType.Text, node.ChildNodes[0].NodeType);
         Assert.AreEqual(location.ToString(), node.ChildNodes[0].InnerText.Trim());
         Assert.AreEqual(HtmlNodeType.Element, node.ChildNodes[1].NodeType);
         Assert.AreEqual("br", node.ChildNodes[1].Name);
         Assert.AreEqual(HtmlNodeType.Text, node.ChildNodes[2].NodeType);
         Assert.AreEqual(location.Country.ToString(), node.ChildNodes[2].InnerText.Trim());
     }
 }
        private static int GetJobCount(LocationReference location)
        {
            switch (location.ToString())
            {
            case MelbourneVic3000:
            case ArmadaleVic3143:
            case SydneyNsw2000:
                return(2);

            case Vic:
            case Nsw:
                return(3);

            case "":
                return(4);

            default:
                return(1);
            }
        }
 protected static string GetDisplayText(LocationReference location, PersonalView viewer)
 {
     return(HtmlUtil.TextToHtml(location.ToString(viewer.CanAccess(PersonalVisibility.CountrySubdivision), viewer.CanAccess(PersonalVisibility.Suburb))));
 }
Exemple #10
0
 protected static string GetJobTitle(int jobIndex, Country country, LocationReference location)
 {
     return(((location.NamedLocation is CountrySubdivision && location.NamedLocation.Name == null) ? country.Name : location.ToString()) + ": " + jobIndex);
 }
Exemple #11
0
        protected ReadOnlyUrl GetCandidateUrl(Guid candidateId, ProfessionalVisibility visibility, LocationReference location, Salary desiredSalary, string desiredJobTitle)
        {
            var sb = new StringBuilder();

            // Location.

            if (!string.IsNullOrEmpty(location.ToString()))
            {
                sb.Append(TextUtil.StripExtraWhiteSpace(TextUtil.StripToAlphaNumericAndWhiteSpace(location.ToString())).ToLower().Replace(' ', '-'));
            }
            else
            {
                if (location.IsCountry)
                {
                    sb.Append(location.Country.ToString().ToLower());
                }
                else
                {
                    sb.Append("-");
                }
            }

            // Salary.

            sb.Append("/");
            if (desiredSalary == null || !visibility.IsFlagSet(ProfessionalVisibility.Salary))
            {
                sb.Append("-");
            }
            else
            {
                desiredSalary = desiredSalary.ToRate(SalaryRate.Year);
                if (desiredSalary.LowerBound != null)
                {
                    if (desiredSalary.UpperBound != null)
                    {
                        sb.Append((int)(desiredSalary.LowerBound) / 1000).Append("k-").Append((int)(desiredSalary.UpperBound) / 1000).Append("k");
                    }
                    else
                    {
                        sb.Append((int)(desiredSalary.LowerBound) / 1000).Append("k-and-above");
                    }
                }
                else
                {
                    sb.Append("up-to-").Append((int)(desiredSalary.UpperBound) / 1000).Append("k");
                }
            }

            // Job title.

            sb.Append("/");
            if (string.IsNullOrEmpty(desiredJobTitle))
            {
                sb.Append("-");
            }
            else
            {
                sb.Append(TextUtil.StripExtraWhiteSpace(TextUtil.StripToAlphaNumericAndSpace(desiredJobTitle)).ToLower().Replace(' ', '-'));
            }

            // Id

            sb.Append("/");
            sb.Append(candidateId.ToString());

            return(new ReadOnlyApplicationUrl(_baseCandidateUrl, sb.ToString()));
        }
Exemple #12
0
        private JobAd PostJobAd(IEmployer employer, LocationReference locationReference)
        {
            var location = locationReference.IsCountry ? locationReference.Country.Name : locationReference.ToString();
            var jobAd    = employer.CreateTestJobAd("Job in " + location + " title", "Job in " + location + " content", null, locationReference);

            _jobAdsCommand.PostJobAd(jobAd);
            return(jobAd);
        }