/// <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>
        /// <param name="dictionary">Which Term dicitonary to search - Cancer.gov or Genetics</param>
        /// <param name="audience">Definition audience - Patient or Health professional</param>
        /// <returns>Returns the search results</returns>
        private TermDictionaryServiceCollection Search(string language, string criteria, int maxRows, bool contains, string dictionary, string audience)
        {
            // create the collection variable
            TermDictionaryServiceCollection sc = new TermDictionaryServiceCollection();

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

                // Call the database query
                TermDictionaryCollection dc =
                    TermDictionaryManager.Search(language, criteria, maxRows, contains, dictionary, audience);

                // Use Linq to extract the data from the business layer and create
                // the service data objects
                var collection = dc.ConvertAll(entry => new TermDictionaryServiceItem(
                                                   entry.GlossaryTermID,
                                                   entry.TermName,
                                                   string.Empty
                                                   ));

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

            return(sc);
        }
        /// <summary>
        /// A private method that is used by both GetTermDictionary by id and Name.
        /// </summary>
        /// <param name="byType">The  value that specifies the type of search to be performed.</param>
        /// <param name="language">This is English or Spanish</param>
        /// <param name="termId">The CDRID of the term</param>
        /// <param name="termName">The term name</param>
        /// <param name="audience">This Patient or HealthProfessional</param>
        /// <returns>TermDictionaryServiceItem instance</returns>
        private TermDictionaryServiceItem getTermDictionary(TermDefinitionByType byType, string language, int termId, string termName, string audience)
        {
            TermDictionaryServiceItem termDicSvcItem = null;

            try
            {
                // language passed to an enum calling this also validates the language value passed is meaningful DisplayLanguage
                DisplayLanguage displayLanguage =
                    (DisplayLanguage)Enum.Parse(typeof(DisplayLanguage), language);

                // Call the database query
                TermDictionaryDataItem termDicDataItem = null;

                if (byType == TermDefinitionByType.ById)
                {
                    termDicDataItem = TermDictionaryManager.GetDefinitionByTermID(language, termId.ToString(), audience, 1);
                }
                else
                {
                    termDicDataItem = TermDictionaryManager.GetDefinitionByTermName(displayLanguage, termName, audience, 1);
                }

                if (termDicDataItem != null)
                {
                    termDicSvcItem = createTermDictionarySvcItem(termDicDataItem);
                }
            }
            catch (Exception ex)
            {
                // Log the error that occured
                CancerGovError.LogError("TermDictionary", 2, ex);
            }

            return(termDicSvcItem);
        }
        /// <summary>
        /// Returns a TermDictionaryServiceList which contains a collection of Term Dictionary
        /// items and the total number of records.
        /// </summary>
        /// <param name="language"></param>
        /// <param name="criteria"></param>
        /// <param name="contains"></param>
        /// <param name="maxRows">Maxrows is treated as recordPerPage or the topN records.
        /// Used for records per page when pagenumber is 0 or greater than 0.
        /// If pagenumber is -1 number records returned is specified by maxRows.
        /// If maxRows=0 and pageNumber=-1 all records are returned.</param>
        /// <param name="pageNumber">Specifies the pagenumber for which the records should be returned.
        /// If pagenumber is -1 number records returned is specified by maxRows.
        /// If maxRows=0 and pageNumber=-1 all records are returned.</param>
        /// <returns></returns>
        private TermDictionaryServiceList getTermDictionaryList(string language, string criteria, bool contains, int maxRows, int pageNumber)
        {
            TermDictionaryServiceList sc = new TermDictionaryServiceList();

            sc.TermDictionaryServiceCollection = new TermDictionaryServiceCollection();
            sc.TotalRecordCount = 0;

            try
            {
                int totalRecordCount = 0;

                // No criteria specified
                if (string.IsNullOrEmpty(criteria))
                {
                    return(sc);
                }

                // if maxrows is 0 and pagenumber is > 0 then return empty.
                if ((maxRows == 0 && pageNumber >= 0) || (maxRows < 0))
                {
                    return(sc);
                }

                if (pageNumber == 0)
                {
                    pageNumber = 1;
                }

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

                // Call the database query
                TermDictionaryCollection dc =
                    TermDictionaryManager.GetTermDictionaryList(language, criteria, contains, maxRows, pageNumber, ref totalRecordCount);

                // Use Linq to extract the data from the business layer and create
                // the service data objects
                sc.TermDictionaryServiceCollection.AddRange(
                    from entry in dc
                    select createTermDictionarySvcItem(entry)
                    );

                sc.TotalRecordCount = totalRecordCount;
            }
            catch (Exception ex)
            {
                // Log the error that occured
                CancerGovError.LogError("TermDictionary", 2, ex);
            }

            return(sc);
        }