Example #1
0
 public static LocationReference Map(this ILocationReferenceEntity entity, ILocationQuery locationQuery)
 {
     return(new LocationReference(
                entity.unstructuredLocation,
                entity.namedLocationId == null ? null : locationQuery.GetNamedLocation(entity.namedLocationId.Value),
                locationQuery.GetCountrySubdivision(entity.countrySubdivisionId),
                entity.localityId == null ? null : locationQuery.GetLocality(entity.localityId.Value))
     {
         Id = entity.id
     });
 }
Example #2
0
        public static IList <NamedLocation> ParseRecords(string value)
        {
            IList <NamedLocation> namedLocations = new List <NamedLocation>();

            string[] locations = value.Split(RecordsDivider);
            foreach (string location in locations)
            {
                // This has the form '<id>=<type>:<displayName>'.  Just use the id to look up the named location.

                string[] sliced = location.Split(NameDivider);
                if (sliced.Length < 1 || sliced.Length > 2)
                {
                    throw new LinkMeApplicationException(ValidationErrorMessages.INVALID_FORMAT + " String: '" + location + "'. " + "User-supplied string: " + value);
                }

                int namedLocationId = ParseUtil.ParseUserInputInt32(sliced[0], "id");
                namedLocations.Add(_locationQuery.GetNamedLocation(namedLocationId, true));
            }

            return(namedLocations);
        }
Example #3
0
        private IList <LocationReference> GetRelocationLocations(ICollection <int> relocationCountryIds, ICollection <int> relocationCountryLocationIds)
        {
            IList <LocationReference> locations = new List <LocationReference>();

            if (relocationCountryIds != null && relocationCountryIds.Count != 0)
            {
                foreach (var countryId in relocationCountryIds)
                {
                    locations.Add(_locationQuery.ResolveLocation(_locationQuery.GetCountry(countryId), null));
                }
            }

            if (relocationCountryLocationIds != null && relocationCountryLocationIds.Count != 0)
            {
                foreach (var locationId in relocationCountryLocationIds)
                {
                    locations.Add(new LocationReference(_locationQuery.GetNamedLocation(locationId)));
                }
            }

            return(locations.Count == 0 ? null : locations);
        }