private static SearchBarVm FillSearchTemplates(SearchBarVm searchBar)
        {
            List <SearchTemplates> searchTemplates = ConfigurationManager.Instance.SearchTemplates;

            if (searchTemplates.Any((SearchTemplates t) => t.CountryCode.Equals("USA", StringComparison.InvariantCultureIgnoreCase)))
            {
                SearchTemplates searchTemplates2 = searchTemplates.First((SearchTemplates t) => t.CountryCode.Equals("USA", StringComparison.InvariantCultureIgnoreCase));
                searchBar.Placeholder = searchTemplates2.Placeholder;
                searchBar.Templates   = new Dictionary <SearchType, List <AutocompleteVm> >();
                SearchType[] array = (SearchType[])Enum.GetValues(typeof(SearchType));
                foreach (SearchType searchType in array)
                {
                    List <AutocompleteVm> list = new List <AutocompleteVm>();
                    foreach (QueryTemplate template in searchTemplates2.Templates)
                    {
                        AutocompleteVm autocompleteVm = new AutocompleteVm();
                        autocompleteVm.Start    = template.LookupLocation;
                        autocompleteVm.Template = template.Template;
                        autocompleteVm.Url      = MslcUrlBuilder.AbsoluteUrl($"/{searchType.UrlPrefix()}{template.Url}");
                        list.Add(autocompleteVm);
                    }
                    searchBar.Templates.Add(searchType, list);
                }
            }
            return(searchBar);
        }
        internal static List <AutocompleteVm> MapToAutocompleteVmList(this IEnumerable <SearchCriteria> criterias, SearchType searchType, string lookupString)
        {
            List <AutocompleteVm> autocompleteVms = new List <AutocompleteVm>();

            foreach (SearchCriteria criteria in criterias)
            {
                AutocompleteVm autocompleteVm = new AutocompleteVm();
                string         lookupLocation = ClientViewModelsProvider.GetLookupLocation(criteria);
                if (lookupString.IsNullOrEmpty() || !lookupLocation.StartsWith(lookupString, StringComparison.InvariantCultureIgnoreCase))
                {
                    autocompleteVm.Start = lookupLocation;
                }
                else
                {
                    autocompleteVm.Start = new string(lookupLocation.Take <char>(lookupString.Count <char>()).ToArray <char>());
                    autocompleteVm.End   = new string(lookupLocation.Skip <char>(lookupString.Count <char>()).ToArray <char>());
                }
                if (string.IsNullOrEmpty(autocompleteVm.LookupLocation))
                {
                    continue;
                }
                autocompleteVm.Url = MslcUrlBuilder.SearchUrl(criteria, searchType);
                SearchDepth depth = criteria.Depth;
                switch (depth)
                {
                case SearchDepth.State:
                {
                    autocompleteVm.Template = "State";
                    break;
                }

                case SearchDepth.City:
                {
                    autocompleteVm.Template = "City";
                    break;
                }

                case SearchDepth.Zip:
                {
                    autocompleteVm.Template = "Zip";
                    break;
                }

                default:
                {
                    depth = SearchDepth.Invalid;
                    break;
                }
                }
                if (depth == SearchDepth.Invalid)
                {
                    continue;
                }
                autocompleteVms.Add(autocompleteVm);
            }
            return(autocompleteVms);
        }