/// <summary>
        /// Gets the Friendly Name to replace a c-code in the URL for the dynamic trial listing page. If there is no exact override for that c-code,
        /// attempt to find a match that contains the given c-code in the EVS mappings.
        /// Sets needsRedirect to true if there is a friendly name override found.
        /// </summary>
        /// <returns>A string with the friendly name for the URL (replaces c-code) if the override exists, otherwise the given c-codes</returns>
        protected KeyValuePair <string, bool> GetFriendlyNameForURL(DynamicTrialListingFriendlyNameMapper FriendlyNameMapping, DynamicTrialListingFriendlyNameMapper FriendlyNameWithOverridesMapping, string param)
        {
            bool needsRedirect = false;

            if (FriendlyNameWithOverridesMapping.MappingContainsCode(param, true))
            {
                // If an exact match is found in the Friendly Name With Overrides mapping, return the friendly name and set redirection bool
                needsRedirect = true;
                return(new KeyValuePair <string, bool>(FriendlyNameWithOverridesMapping.GetFriendlyNameFromCode(param, true), needsRedirect));
            }
            else
            {
                if (FriendlyNameMapping.MappingContainsCode(param, false))
                {
                    // If an exact match is found in the Friendly Name mapping (without overrides), return the friendly name and set redirection bool
                    // Also if matches are found that contain the given codes and all have the same friendly name, return that friendly name and set redirection bool
                    needsRedirect = true;

                    string evsFriendlyName = FriendlyNameMapping.GetFriendlyNameFromCode(param, false);
                    string codesToOverride = FriendlyNameMapping.GetCodeFromFriendlyName(evsFriendlyName);

                    if (FriendlyNameWithOverridesMapping.MappingContainsCode(codesToOverride, true))
                    {
                        // If an exact match is found in the Friendly Name With Overrides mapping, return the friendly name and set redirection bool
                        return(new KeyValuePair <string, bool>(FriendlyNameWithOverridesMapping.GetFriendlyNameFromCode(codesToOverride, true), needsRedirect));
                    }
                    else
                    {
                        return(new KeyValuePair <string, bool>(FriendlyNameMapping.GetFriendlyNameFromCode(param, false), needsRedirect));
                    }
                }
                else
                {
                    if (FriendlyNameMapping.MappingContainsFriendlyName(param))
                    {
                        string codesToOverride = FriendlyNameMapping.GetCodeFromFriendlyName(param);

                        if (FriendlyNameWithOverridesMapping.MappingContainsCode(codesToOverride, true))
                        {
                            // If an exact match is found in the Friendly Name With Overrides mapping, return the friendly name and set redirection bool
                            if (!string.Equals(param, FriendlyNameWithOverridesMapping.GetFriendlyNameFromCode(codesToOverride, true)))
                            {
                                needsRedirect = true;
                                return(new KeyValuePair <string, bool>(FriendlyNameWithOverridesMapping.GetFriendlyNameFromCode(codesToOverride, true), needsRedirect));
                            }
                        }
                    }
                }
            }

            return(new KeyValuePair <string, bool>(param, needsRedirect));
        }
        /// <summary>
        /// Replaces the Placeholder Codes (or text) with Override Labels
        /// </summary>
        /// <param name="codes"></param>
        /// <returns>A string with the override text</returns>
        private string GetOverride(DynamicTrialListingFriendlyNameMapper FriendlyNameMapping,
                                   DynamicTrialListingFriendlyNameMapper FriendlyNameWithOverridesMapping,
                                   DynamicTrialListingMapper LabelMapping,
                                   string valToOverride,
                                   bool needsTitleCase)
        {
            // Get friendly name to c-code mapping
            if (FriendlyNameWithOverridesMapping.MappingContainsFriendlyName(valToOverride.ToLower()))
            {
                valToOverride = FriendlyNameWithOverridesMapping.GetCodeFromFriendlyName(valToOverride);
            }
            else
            {
                if (FriendlyNameMapping.MappingContainsFriendlyName(valToOverride.ToLower()))
                {
                    valToOverride = FriendlyNameMapping.GetCodeFromFriendlyName(valToOverride);
                }
            }

            string overrideText = "";

            // Add check for whether override/EVS mapping has all of the codes.
            // If so, keep as is. If not, split and find the first match.

            // If combination of codes is in label mappings, set override
            if (LabelMapping.MappingContainsKey(valToOverride))
            {
                if (needsTitleCase)
                {
                    overrideText = LabelMapping.GetTitleCase(valToOverride);
                }
                else
                {
                    overrideText = LabelMapping.Get(valToOverride);
                }
            }
            // Raise 404 error if overrides aren't found
            else
            {
                throw new Exception(String.Format("" + "Invalid parameter in dynamic listing page: {0} does not have override", valToOverride));
            }

            return(overrideText);
        }
 /// <summary>
 /// Checks to see if the lookup contains an entry for the pretty name
 /// </summary>
 /// <param name="value">The pretty name to lookup</param>
 /// <returns>True or false based on the existance of the pretty name in the lookup</returns>
 public bool MappingContainsFriendlyName(string value)
 {
     return(_mapper.MappingContainsFriendlyName(value));
 }