Exemplo n.º 1
0
        public void OverrideMappingContainsCodes()
        {
            DynamicTrialListingFriendlyNameMapper mapper = GetMappingService("DLPFriendlyNameMapping.txt", "DLPFriendlyNameOverrideMapping.txt", true);

            Assert.Equal(false, mapper.MappingContainsCode("c4872", true));
            Assert.Equal(false, mapper.MappingContainsCode("c118827", true));
            Assert.Equal(true, mapper.MappingContainsCode("c118827,c4815", true));
        }
        /// <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>
 /// Checks to see if the lookup contains an entry for the C-code(s), whether an exact match or contained in keys that all have the same friendly name.
 /// </summary>
 /// <param name="key">The C-code(s) to lookup</param>
 /// <returns>True or false based on the existance of the C-code(s) in the lookup</returns>
 public bool MappingContainsCode(string code, bool needsExactMatch)
 {
     return(_mapper.MappingContainsCode(code, needsExactMatch));
 }