Exemple #1
0
        protected override IList <string> GetSuggestionList(HttpContext context, int maxResults)
        {
            // Extract the parameters.

            string location = context.Request.Params[LocationParameter];

            if (string.IsNullOrEmpty(location))
            {
                return(null);
            }

            string method = context.Request.Params[MethodParameter];

            // At the moment only Australia is supported.

            int countryId = ParseUtil.ParseUserInputInt32(context.Request.Params[CountryParameter], "country ID");

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

            // Get the partial matches.

            var country = /*RequestContext.Current.LocationContext.Country*/ _locationQuery.GetCountry("Australia");

            var matches = string.Equals(method, UI.Controls.Common.Location.ResolutionMethod.NamedLocation.ToString(), StringComparison.InvariantCultureIgnoreCase)
                ? _locationQuery.FindPartialMatchedLocations(country, location, maxResults)
                : _locationQuery.FindPartialMatchedPostalSuburbs(country, location, maxResults);

            return(matches.Select(p => p.Key).ToArray());
        }
Exemple #2
0
        public ActionResult FindPartialMatchedLocations(int?countryId, string location, int?maxResults)
        {
            var country = countryId == null ? ActivityContext.Location.Country : _locationQuery.GetCountry(countryId.Value);

            maxResults = maxResults ?? DefaultMaxResults;
            var partialMatches = _locationQuery.FindPartialMatchedLocations(country, location, maxResults.Value);

            return(Json((from m in partialMatches select m.Key).ToArray()));
        }
Exemple #3
0
        private void Find(string location, int maximum, params string[] expected)
        {
            var matches = _locationQuery.FindPartialMatchedLocations(_australia, location, maximum);

            Assert.IsNotNull(matches);
            Assert.AreEqual(expected.Length, matches.Count);
            for (var index = 0; index < matches.Count; ++index)
            {
                Assert.AreEqual(expected[index], matches[index].Key);
            }
        }
Exemple #4
0
        protected override void ProcessRequestImpl(HttpContext context)
        {
            context.Response.ContentType = "text/html";

            // Extract the parameters.

            string location  = context.Request.QueryString[LocationParameter];
            int    maximum   = ParseUtil.ParseUserInputInt32Optional(context.Request.QueryString[MaximumParameter], MaximumParameter, MaximumDefault);
            int    countryId = ParseUtil.ParseUserInputInt32Optional(context.Request.QueryString[CountryParameter], CountryParameter, /*RequestContext.Current.LocationContext.Country*/ _locationQuery.GetCountry("Australia").Id);

            Country country = _locationQuery.GetCountry(countryId);

            if (country == null)
            {
                throw new ServiceEndUserException(String.Format(ValidationErrorMessages.INVALID_COUNTRY_ID_SPECIFIED, countryId));
            }

            // Get the matches.

            IList <PartialMatch> locations;

            if (String.IsNullOrEmpty(location))
            {
                // An empty location means get all subdivisions and regions with no limitation.

                locations = new List <PartialMatch>();
                Add(_locationQuery.GetCountrySubdivisions(country), locations);
                Add(_locationQuery.GetRegions(country), locations);
            }
            else
            {
                // Get the partially matching locations.

                locations = _locationQuery.FindPartialMatchedLocations(country, location, maximum);
            }

            context.Response.Write(GetRecords(locations));
        }