コード例 #1
0
        public void LocalityTest()
        {
            var bentleigh = _locationQuery.ResolveLocation(_australia, "3204");
            var mapped    = _mapper.Map(bentleigh);

            Assert.AreEqual("20-168-1", mapped.id);
        }
コード例 #2
0
        private void DeconvertLocation(JobAdSearchCriteria criteria, IGetValues values)
        {
            var location = values.GetStringValue(JobAdSearchCriteriaKeys.Location);

            Country country   = null;
            var     countryId = values.GetIntValue(JobAdSearchCriteriaKeys.CountryId);

            if (countryId != null)
            {
                country = _locationQuery.GetCountry(countryId.Value);
            }
            else
            {
                // Try the old value.

                countryId = values.GetIntValue(JobAdSearchCriteriaKeys.Country);
                if (countryId != null)
                {
                    country = _locationQuery.GetCountry(countryId.Value);
                }
            }

            if (country != null)
            {
                criteria.Location = _locationQuery.ResolveLocation(country, location);
            }
            else if (!string.IsNullOrEmpty(location))
            {
                criteria.Location = _locationQuery.ResolveLocation(_locationQuery.GetCountries()[0], location);
            }

            criteria.Distance = values.GetIntValue(JobAdSearchCriteriaKeys.Distance);
        }
コード例 #3
0
        public void TestAddLocation()
        {
            var employer = CreateEmployer();
            var country  = _locationQuery.GetCountry("Australia");

            // No location.

            var jobAd = new JobAd
            {
                PosterId    = employer.Id,
                Title       = string.Format(TitleFormat, 0),
                Description =
                {
                    Content = string.Format(ContentFormat, 1),
                }
            };

            _jobAdsCommand.CreateJobAd(jobAd);

            AssertLocation(jobAd.Description.Location, _jobAdsQuery.GetJobAd <JobAd>(jobAd.Id).Description.Location);

            // Add it.

            jobAd.Description.Location = _locationQuery.ResolveLocation(country, Location2);
            _jobAdsCommand.UpdateJobAd(jobAd);

            AssertLocation(jobAd.Description.Location, _jobAdsQuery.GetJobAd <JobAd>(jobAd.Id).Description.Location);
        }
コード例 #4
0
        public bool TryMap(string location, out LocationReference locationReference)
        {
            var address = ParseLocation(location);

            // Use the postcode whenever possible.

            if (!string.IsNullOrEmpty(address.Postcode))
            {
                locationReference = _locationQuery.ResolveLocation(_locationQuery.GetCountry("Australia"), address.Postcode);
                if (locationReference.IsFullyResolved)
                {
                    return(true);
                }
            }

            // Try well-known area names used by MyCarrer.

            if (!string.IsNullOrEmpty(address.State) && !string.IsNullOrEmpty(address.Area))
            {
                Dictionary <string, NamedLocation> knownAreas;
                NamedLocation namedLocation;
                if (_knownAreasByState.TryGetValue(address.State, out knownAreas) &&
                    knownAreas.TryGetValue(address.Area, out namedLocation))
                {
                    locationReference = new LocationReference(namedLocation);
                    return(true);
                }
            }

            // Resolve the state only.

            locationReference = _locationQuery.ResolveLocation(_locationQuery.GetCountry("Australia"), address.State);
            return(false);
        }
コード例 #5
0
ファイル: WorldIndexTests.cs プロジェクト: formist/LinkMe
        public void DistanceTest()
        {
            var bentleigh = _locationQuery.ResolveLocation(_australia, "3204").Locality;
            var stkilda   = _locationQuery.ResolveLocation(_australia, "3182").Locality;

            Assert.AreEqual(8, _world.Distance(bentleigh, stkilda));
            Assert.AreEqual(8, _world.Distance(stkilda, bentleigh));
            Assert.AreEqual(0, _world.Distance(stkilda, stkilda));
        }
コード例 #6
0
        public void TestDistance()
        {
            var members = CreateMembers();

            // Simple search in Melbourne VIC 3000 (default distance = 50).

            var criteria = new MemberSearchCriteria();

            criteria.SetKeywords(BusinessAnalyst);
            criteria.Location = _locationQuery.ResolveLocation(_australia, MelbourneVic3000);
            var model = Search(criteria);

            AssertMembers(model, members[MelbourneVic3000], members[ArmadaleVic3143], members[Melbourne]);

            // Search within 5 km: no Armadale jobs.

            criteria.Distance = 5;
            model             = Search(criteria);
            AssertMembers(model, members[MelbourneVic3000]);

            // Search within 10 km: Armadale back in.

            criteria.Distance = 10;
            model             = Search(criteria);
            AssertMembers(model, members[MelbourneVic3000], members[ArmadaleVic3143]);

            // Search within 100 km: Norlane included.

            criteria.Distance = 100;
            model             = Search(criteria);
            AssertMembers(model, members[MelbourneVic3000], members[ArmadaleVic3143], members[NorlaneVic3214], members[Melbourne]);

            // Simple search in Norlane VIC 3124 (default distance = 50).

            criteria.Location = _locationQuery.ResolveLocation(_australia, NorlaneVic3214);
            criteria.Distance = null;
            model             = Search(criteria);
            AssertMembers(model, members[NorlaneVic3214]);

            // Search within 5 km.

            criteria.Distance = 5;
            model             = Search(criteria);
            AssertMembers(model, members[NorlaneVic3214]);

            // Search within 10 km.

            criteria.Distance = 10;
            model             = Search(criteria);
            AssertMembers(model, members[NorlaneVic3214]);

            // Search within 100 km.

            criteria.Distance = 100;
            model             = Search(criteria);
            AssertMembers(model, members[MelbourneVic3000], members[ArmadaleVic3143], members[NorlaneVic3214]);
        }
コード例 #7
0
        public void TestAddressComplete()
        {
            var member = new Member {
                Address = new Address {
                    Location = _locationQuery.ResolveLocation(_locationQuery.GetCountry(Country), Location)
                }
            };
            var candidate = new Candidate();

            AssertStatus(member, candidate, null, 10, MemberItem.Address);
        }
コード例 #8
0
        public void TestMapState()
        {
            var    location = _locationQuery.ResolveLocation(_australia, "VIC");
            string state;
            string postcode;
            string suburb;

            location.Map(out state, out postcode, out suburb);

            Assert.AreEqual("VIC", state);
            Assert.AreEqual("3000", postcode);
            Assert.AreEqual("MELBOURNE", suburb);
        }
コード例 #9
0
        private JobAd CreateJobAd()
        {
            var jobPoster = CreateJobPoster();

            return(CreateJobAd(
                       jobPoster,
                       0,
                       j =>
            {
                j.Title = JobTitle;
                j.Description.Location = _locationQuery.ResolveLocation(_locationQuery.GetCountry(Country), Location);
            }));
        }
コード例 #10
0
        public void TestUpdateAllJobAdObjects()
        {
            var employer = CreateEmployer();

            var country    = _locationQuery.GetCountry("Australia");
            var industries = _industriesQuery.GetIndustries();

            var jobAd = new JobAd
            {
                PosterId       = employer.Id,
                Title          = string.Format(TitleFormat, 0),
                ContactDetails = new ContactDetails
                {
                    FirstName    = string.Format(FirstNameFormat, 0),
                    LastName     = string.Format(LastNameFormat, 0),
                    EmailAddress = string.Format(EmailAddressFormat, 0),
                    CompanyName  = string.Format(CompanyFormat, 0),
                },
                Description =
                {
                    Content    = string.Format(ContentFormat,                    1),
                    Location   = _locationQuery.ResolveLocation(country, Location1),
                    Industries = new List <Industry>
                    {
                        industries[0],
                        industries[1],
                    }
                }
            };

            _jobAdsCommand.CreateJobAd(jobAd);

            // Update it.

            jobAd.ContactDetails = new ContactDetails
            {
                FirstName    = string.Format(FirstNameFormat, 1),
                LastName     = string.Format(LastNameFormat, 1),
                EmailAddress = string.Format(EmailAddressFormat, 1),
                CompanyName  = string.Format(CompanyFormat, 1),
            };

            jobAd.Description.Location   = _locationQuery.ResolveLocation(country, Location2);
            jobAd.Description.Industries = new List <Industry>
            {
                industries[2]
            };

            _jobAdsCommand.UpdateJobAd(jobAd);
        }
コード例 #11
0
        private Organisation CreateOrganisation(EmployerAccount account)
        {
            var organisation = new Organisation
            {
                Name        = account.OrganisationName,
                AffiliateId = GetEmployerAffiliateId(),
                Address     = new Address {
                    Location = _locationQuery.ResolveLocation(GetCurrentCountry(), account.Location)
                },
            };

            _organisationsCommand.CreateOrganisation(organisation);
            return(organisation);
        }
コード例 #12
0
        private void UpdateMemberModel(PersonalDetailsMemberModel memberModel, Guid?parsedResumeId)
        {
            if (parsedResumeId == null)
            {
                return;
            }
            var parsedResume = _resumesQuery.GetParsedResume(parsedResumeId.Value);

            if (parsedResume == null)
            {
                return;
            }

            // Update those bits that are not already set.

            if (string.IsNullOrEmpty(memberModel.FirstName))
            {
                memberModel.FirstName = parsedResume.FirstName;
            }
            if (string.IsNullOrEmpty(memberModel.LastName))
            {
                memberModel.LastName = parsedResume.LastName;
            }

            var country = _locationQuery.GetCountry(memberModel.CountryId);

            if (string.IsNullOrEmpty(memberModel.Location))
            {
                memberModel.Location = _locationQuery.ResolveLocation(country, parsedResume.Address == null ? null : parsedResume.Address.Location).ToString().NullIfEmpty();
            }

            if (string.IsNullOrEmpty(memberModel.EmailAddress))
            {
                if (parsedResume.EmailAddresses != null && parsedResume.EmailAddresses.Count != 0)
                {
                    memberModel.EmailAddress = parsedResume.EmailAddresses[0].Address;
                }
            }

            if (string.IsNullOrEmpty(memberModel.PhoneNumber))
            {
                var phoneNumber = GetPhoneNumber(parsedResume);
                if (phoneNumber != null)
                {
                    memberModel.PhoneNumber     = phoneNumber.Number;
                    memberModel.PhoneNumberType = phoneNumber.Type;
                }
            }
        }
コード例 #13
0
ファイル: HasAppliedTests.cs プロジェクト: formist/LinkMe
 private JobAdSearchCriteria CreateCriteria(bool?hasApplied)
 {
     return(new JobAdSearchCriteria
     {
         IndustryIds = IndustryIds.Select(i => new Guid(i)).ToArray(),
         Location = _locationQuery.ResolveLocation(_locationQuery.GetCountry(Country), Location),
         Distance = 50,
         SortCriteria = new JobAdSearchSortCriteria
         {
             SortOrder = JobAdSortOrder.CreatedTime,
         },
         Recency = new TimeSpan(2592000000000),
         HasApplied = hasApplied,
     });
 }
コード例 #14
0
 private HomeModel CreateHomeModel(Login login, bool acceptTerms)
 {
     return(new HomeModel
     {
         Login = login,
         AcceptTerms = acceptTerms,
         Reference = new ReferenceModel
         {
             KeywordLocationSearch = new KeywordLocationSearchModel
             {
                 Criteria = new MemberSearchCriteria
                 {
                     Distance = MemberSearchCriteria.DefaultDistance,
                     Location = _locationQuery.ResolveLocation(ActivityContext.Location.Country, null),
                 },
                 CanSearchByName = false,
                 Distances = Reference.Distances,
                 DefaultDistance = MemberSearchCriteria.DefaultDistance,
                 Countries = _locationQuery.GetCountries(),
                 DefaultCountry = ActivityContext.Location.Country,
             },
         },
         AppStoreUrl = AppStoreUrl,
     });
 }
コード例 #15
0
        public void TestAddress()
        {
            // Create organisation.

            var organisation = new Organisation
            {
                Name    = OrganisationName,
                Address = new Address {
                    Location = _locationQuery.ResolveLocation(_locationQuery.GetCountry(Country), Location)
                },
            };

            _organisationsCommand.CreateOrganisation(organisation);
            AssertOrganisation(organisation, _organisationsQuery.GetOrganisation(organisation.Id));

            // Create employers.

            var employer = new Employer
            {
                EmailAddress = new EmailAddress {
                    Address = EmailAddress, IsVerified = true
                },
                FirstName   = FirstName,
                LastName    = LastName,
                PhoneNumber = new PhoneNumber {
                    Number = PhoneNumber
                },
                Organisation = organisation,
            };

            _employersCommand.CreateEmployer(employer);

            AssertOrganisation(organisation, _employersQuery.GetEmployer(employer.Id).Organisation);
        }
コード例 #16
0
ファイル: VerticalsModule.cs プロジェクト: formist/LinkMe
        private IRegisteredUser CreateMember(Guid verticalId, ExternalUserData userData)
        {
            // User does not exist, create them now making sure they are activated.

            var member = new Member
            {
                FirstName      = userData.FirstName,
                LastName       = userData.LastName,
                EmailAddresses = new List <EmailAddress> {
                    new EmailAddress {
                        Address = userData.EmailAddress, IsVerified = true
                    }
                },
                Address = new Address {
                    Location = _locationQuery.ResolveLocation(ActivityContext.Current.Location.Country, null)
                },
                VisibilitySettings = new VisibilitySettings(),
                IsActivated        = true,
            };

            _memberAccountsCommand.CreateMember(member, new ExternalCredentials {
                ProviderId = verticalId, ExternalId = userData.ExternalId
            }, verticalId);
            return(member);
        }
コード例 #17
0
        private void UpdateMember(Member member, ContactDetailsMemberModel memberModel)
        {
            // Names.

            member.FirstName = memberModel.FirstName;
            member.LastName  = memberModel.LastName;

            // Location.

            var country = _locationQuery.GetCountry(memberModel.CountryId ?? ActivityContext.Location.Country.Id);

            member.Address.Location = _locationQuery.ResolveLocation(country, memberModel.Location);

            // Email addresses.

            member.EmailAddresses = new List <EmailAddress> {
                new EmailAddress {
                    Address = memberModel.EmailAddress
                }
            };
            if (!string.IsNullOrEmpty(memberModel.SecondaryEmailAddress))
            {
                member.EmailAddresses.Add(new EmailAddress {
                    Address = memberModel.SecondaryEmailAddress
                });
            }

            // Phone numbers.

            member.PhoneNumbers = new List <PhoneNumber> {
                new PhoneNumber {
                    Number = memberModel.PhoneNumber, Type = memberModel.PhoneNumberType
                }
            };
            if (!string.IsNullOrEmpty(memberModel.SecondaryPhoneNumber))
            {
                member.PhoneNumbers.Add(new PhoneNumber {
                    Number = memberModel.SecondaryPhoneNumber, Type = memberModel.SecondaryPhoneNumberType
                });
            }

            // Others.

            member.EthnicStatus = memberModel.EthnicStatus;
            member.Gender       = memberModel.Gender;
            member.DateOfBirth  = memberModel.DateOfBirth;
        }
コード例 #18
0
        public void TestLocation()
        {
            var country = _locationQuery.GetCountry("Australia");

            Test(new JobAdSearchCriteria {
                Location = _locationQuery.ResolveLocation(country, null)
            }, "CountryId=1");
            Test(new JobAdSearchCriteria {
                Location = _locationQuery.ResolveLocation(country, "Melbourne")
            }, "CountryId=1&Location=Melbourne");
            Test(new JobAdSearchCriteria {
                Location = _locationQuery.ResolveLocation(country, "VIC")
            }, "CountryId=1&Location=VIC");
            Test(new JobAdSearchCriteria {
                Location = _locationQuery.ResolveLocation(country, "Melbourne VIC 3000")
            }, "CountryId=1&Location=Melbourne+VIC+3000");
        }
コード例 #19
0
        public void TestLocation()
        {
            var country = _locationQuery.GetCountry("Australia");

            Test(new MemberSearchCriteria {
                Location = _locationQuery.ResolveLocation(country, null)
            });
            Test(new MemberSearchCriteria {
                Location = _locationQuery.ResolveLocation(country, "Melbourne")
            });
            Test(new MemberSearchCriteria {
                Location = _locationQuery.ResolveLocation(country, "VIC")
            });
            Test(new MemberSearchCriteria {
                Location = _locationQuery.ResolveLocation(country, "Melbourne VIC 3000")
            });
        }
コード例 #20
0
 private Address GetAddress(string location)
 {
     return(string.IsNullOrEmpty(location)
         ? null
         : new Address {
         Location = _locationQuery.ResolveLocation(ActivityContext.Location.Country, location)
     });
 }
コード例 #21
0
        public void TestRelocationCountry()
        {
            // Member is located in an unstructured location in Australia, and is willing to relocate to Australia.

            var content = new MemberContent
            {
                Member = new Member
                {
                    Id      = Guid.NewGuid(),
                    Address = new Address {
                        Location = _locationQuery.ResolveLocation(_locationQuery.GetCountry("Australia"), "Winnipeg MB r3e 1w1")
                    },
                },
                Candidate = new Candidate
                {
                    RelocationPreference = RelocationPreference.Yes,
                    RelocationLocations  = new List <LocationReference>
                    {
                        _locationQuery.ResolveLocation(_locationQuery.GetCountry("Australia"), null),
                    },
                }
            };

            IndexContent(content);

            // Search in Mackay.

            var memberQuery = new MemberSearchQuery
            {
                Location          = _locationQuery.ResolveLocation(_locationQuery.GetCountry("Australia"), "Mackay QLD 4740"),
                Distance          = 5,
                IncludeRelocating = false,
            };
            var results = Search(memberQuery, 0, 10);

            Assert.AreEqual(0, results.MemberIds.Count);

            memberQuery = new MemberSearchQuery
            {
                Location          = _locationQuery.ResolveLocation(_locationQuery.GetCountry("Australia"), "Mackay QLD 4740"),
                Distance          = 5,
                IncludeRelocating = true,
            };
            results = Search(memberQuery, 0, 10);
            Assert.AreEqual(1, results.MemberIds.Count);
        }
コード例 #22
0
        public void TestLocation()
        {
            var criteria = new JobAdSearchCriteria();

            criteria.SetKeywords(null, null, "Test", null);

            var country = _locationQuery.GetCountry("Australia");

            criteria.Location = _locationQuery.ResolveLocation(country, null);
            Test(criteria, "test jobs in australia");
            criteria.Location = _locationQuery.ResolveLocation(country, "Melbourne");
            Test(criteria, "test jobs in melbourne australia");
            criteria.Location = _locationQuery.ResolveLocation(country, "VIC");
            Test(criteria, "test jobs in vic australia");
            criteria.Location = _locationQuery.ResolveLocation(country, "Melbourne VIC 3000");
            Test(criteria, "test jobs in melbourne vic 3000 australia");
        }
コード例 #23
0
        public void TestValidAustralianAddress()
        {
            var member = CreateMember();

            member.Address = new Address {
                Location = _locationQuery.ResolveLocation(_australia, "Sydney 2000 NSW")
            };

            try
            {
                member.Validate();
            }
            catch (ValidationErrorsException)
            {
                Assert.Fail();
            }
        }
コード例 #24
0
ファイル: ResolveLocation.cs プロジェクト: formist/LinkMe
        public string ResolveNamedLocation(int countryId, string location)
        {
            try
            {
                if (string.IsNullOrEmpty(location))
                {
                    return(string.Empty);
                }

                // If the country is not specified then use the current context.

                Country country = _locationQuery.GetCountry(countryId);
                if (country == null)
                {
                    country = /*RequestContext.Current.LocationContext.Country*/ _locationQuery.GetCountry("Australia");
                }

                // Resolve.

                var locationReference = _locationQuery.ResolveLocation(country, location);

                if (!locationReference.IsFullyResolved)
                {
                    // Not everything could be resolved.

                    return(string.Empty);
                }
                else
                {
                    // Resolve based on what the location was resolved down to.

                    if (locationReference.PostalSuburb != null)
                    {
                        return(Resolve(country, locationReference.PostalSuburb, location));
                    }
                    else if (locationReference.PostalCode != null)
                    {
                        return(Resolve(country, locationReference.PostalCode, location));
                    }
                    else if (locationReference.Locality != null)
                    {
                        return(Resolve(country, locationReference.Locality, location));
                    }
                    else if (locationReference.Region != null)
                    {
                        return(Resolve(country, locationReference.Region, location));
                    }
                    else
                    {
                        return(Resolve(country, locationReference.CountrySubdivision, location));
                    }
                }
            }
            catch (Exception)
            {
                return(string.Empty);
            }
        }
コード例 #25
0
        public void TestCreate()
        {
            // Create.

            var location     = _locationQuery.ResolveLocation(_locationQuery.GetCountry("Australia"), Location);
            var organisation = new Organisation {
                Name = Name, Address = new Address {
                    Line1 = Line1, Line2 = Line2, Location = location
                }
            };

            _organisationsCommand.CreateOrganisation(organisation);

            Assert.AreNotEqual(Guid.Empty, organisation.Address.Id);
            Assert.AreNotEqual(Guid.Empty, organisation.Address.Location.Id);

            // Assert.

            organisation = _organisationsQuery.GetOrganisation(organisation.Id);
            Assert.AreEqual(Line1, organisation.Address.Line1);
            Assert.AreEqual(Line2, organisation.Address.Line2);
            Assert.AreEqual(location.Country.Id, organisation.Address.Location.Country.Id);
            Assert.AreEqual(location.CountrySubdivision.Id, organisation.Address.Location.CountrySubdivision.Id);
            Assert.AreEqual(location.NamedLocation.Id, organisation.Address.Location.NamedLocation.Id);
            Assert.AreEqual(location.Locality.Id, organisation.Address.Location.Locality.Id);
        }
コード例 #26
0
 public EmployerMemberViewsTests()
 {
     _industries = new List <Industry> {
         _industriesQuery.GetIndustries()[2]
     };
     _relocationLocations = new List <LocationReference> {
         _locationQuery.ResolveLocation(_locationQuery.GetCountry(1), "Melbourne VIC 3000")
     };
 }
コード例 #27
0
ファイル: LinkedInTests.cs プロジェクト: formist/LinkMe
        public void TestCreateFullProfile()
        {
            var userId = Guid.NewGuid();

            var profile = new LinkedInProfile
            {
                Id               = LinkedInId,
                UserId           = userId,
                FirstName        = FirstName,
                LastName         = LastName,
                OrganisationName = OrganisationName,
                Industries       = new[] { _industriesQuery.GetIndustry(Industry) },
                Location         = _locationQuery.ResolveLocation(_locationQuery.GetCountry(Country), Location),
            };

            _linkedInCommand.UpdateProfile(profile);
            AssertProfile(profile, _linkedInQuery.GetProfile(LinkedInId));
            AssertProfile(profile, _linkedInQuery.GetProfile(profile.UserId));
        }
コード例 #28
0
 private void AddMember(MemberContent content)
 {
     content.Member.Address = new Address {
         Location = _locationQuery.ResolveLocation(_locationQuery.GetCountry("Australia"), null)
     };
     _membersCommand.CreateMember(content.Member);
     content.Candidate.Id = content.Member.Id;
     _candidatesCommand.CreateCandidate(content.Candidate);
     _searchService.UpdateMember(content.Member.Id);
 }
コード例 #29
0
ファイル: JobAdModelConverter.cs プロジェクト: formist/LinkMe
        private void DeconvertLocation(JobAdModel jobAd, IGetValues values)
        {
            var location = values.GetStringValue(Keys.Location);

            Country country   = null;
            var     countryId = values.GetIntValue(Keys.CountryId);

            if (countryId != null)
            {
                country = _locationQuery.GetCountry(countryId.Value);
            }

            if (country != null)
            {
                jobAd.Location = _locationQuery.ResolveLocation(country, location);
            }
            else if (!string.IsNullOrEmpty(location))
            {
                jobAd.Location = _locationQuery.ResolveLocation(_locationQuery.GetCountries()[0], location);
            }
        }
コード例 #30
0
 private Member CreateMember(int index)
 {
     return(new Member
     {
         FirstName = string.Format(FirstNameFormat, index),
         LastName = string.Format(LastNameFormat, index),
         VisibilitySettings = new VisibilitySettings(),
         Address = new Address {
             Location = _locationQuery.ResolveLocation(_locationQuery.GetCountry("Australia"), null)
         },
     });
 }