Beispiel #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());
        }
Beispiel #2
0
        public ActionResult FindPartialMatchedPostalSuburbs(int?countryId, string location, int?maxResults)
        {
            var country = countryId == null ? ActivityContext.Location.Country : _locationQuery.GetCountry(countryId.Value);

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

            return(Json((from m in partialMatches select m.Key).ToArray()));
        }
        private void Find(string location, int maximum, params string[] expected)
        {
            IList <PartialMatch> matches = _locationQuery.FindPartialMatchedPostalSuburbs(_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);
            }
        }