Example #1
0
        /// <summary>
        /// Gets the suggestions by search string.
        /// </summary>
        /// <param name="client">IRoadsService instance. </param>
        /// <param name="searchString">The search string.</param>
        /// <param name="language">The language of user.</param>
        /// <returns><see cref="SuggestionsModel"/> which contains search results.</returns>
        public static SuggestionsModel GetSuggestions(IRoadsService client, string searchString, string language)
        {
            var suggestionsModel = new SuggestionsModel();
            Suggestion[] suggestions = client.GetSuggestions(searchString, language);

            if (suggestions != null && suggestions.Length != 0)
            {
                foreach (Suggestion suggestion in suggestions)
                {
                    suggestionsModel.suggestions.Add(new Models.Suggestion
                    {
                        data = suggestion.CityNodeId.ToString(CultureInfo.InvariantCulture),
                        value = String.Format("{0}{1}", suggestion.SuggestionCityName, suggestion.SuggestionRegionName)
                    });
                }
            }
            return suggestionsModel;
        }