Example #1
0
        public JArray translateToDisplayName(JArray array, string type)
        {
            var displayNames             = crmService.GetAttributeDisplayName(type);
            var contactsWithDisplayNames = new JArray();

            foreach (var contact in array.Children <JObject>())
            {
                var newContact = new JObject();
                foreach (var keyValue in contact.Properties())
                {
                    if (displayNames.ContainsKey(keyValue.Name.ToString().ToLower()))
                    {
                        string displayName;
                        displayNames.TryGetValue(keyValue.Name.ToString().ToLower(), out displayName);

                        if (newContact.Property(displayName) == null)
                        {
                            newContact.Add(displayName, keyValue.Value);
                        }
                        else
                        {
                            newContact.Add(displayName + " 2", keyValue.Value);
                        }
                    }
                }
                contactsWithDisplayNames.Add(newContact);
            }

            return(contactsWithDisplayNames);
        }