Beispiel #1
0
        /// <summary>
        /// Method used to query database for English language results. This will return the
        /// data in XML format. There is no way to create an additional WebGet so that we
        /// can return the same data in JSON format.
        /// </summary>
        /// <param name="language">The language needed to do the lookup</param>
        /// <param name="criteria">The partial text used to query the database</param>
        /// <param name="maxRows">The maximum number of rows that the database will return. a value of zero will return the entire set</param>
        /// <param name="contains">Indicator on whether the text is to be search from the beginning of the text or anywhere in the string</param>
        /// <returns>Returns the search results</returns>
        private AutoSuggestSearchServiceCollection Search(string language, string criteria, int maxRows, bool contains)
        {
            // create the collection variable
            AutoSuggestSearchServiceCollection sc = new AutoSuggestSearchServiceCollection();

            try
            {
                // language passed to an enum
                DisplayLanguage displayLanguage =
                    (DisplayLanguage)Enum.Parse(typeof(DisplayLanguage), language);

                // Call the database query
                AutoSuggestSearchCollection dc =
                    AutoSuggestSearchManager.Search(language, criteria, maxRows, contains);

                // Use Linq to extract the data from the business layer and create
                // the service data objects
                // TermID is 0 always , that value is not part of the result received from the call to
                // Stroed procedure.But can be used in the future for other purposes.
                var collection = dc.ConvertAll(entry => new AutoSuggestSearchServiceItem(
                                                   entry.TermID,
                                                   entry.TermName,
                                                   string.Empty
                                                   ));

                sc.AddRange(collection);
            }
            catch (Exception ex)
            {
                // Log the error that occured
                CancerGovError.LogError("AutoSuggestSearch", 2, ex);
            }

            return(sc);
        }