Exemple #1
0
 private void AddToTempList(Helpers.Attribute attr)
 {
     Helpers.Attribute contactDetails = new Helpers.Attribute();
     contactDetails.AttributeId    = attr.AttributeId;
     contactDetails.AttributeName  = attr.AttributeName;
     contactDetails.AttributeValue = attr.AttributeValue;
     contactDetails.Description    = attr.Description;
     contactDetails.Isprimary      = attr.Isprimary;
     contactDetails.IsMandatory    = attr.IsMandatory;
     contactDetails.IsAltered      = false;
     TempOldContact.Add(contactDetails);
 }
Exemple #2
0
        public ObservableCollection <Helpers.Attribute> ConvertToObservableCollection(AttributesList attribute)
        {
            Settings.ContactDataContext contactContext = Settings.ContactDataContext.GetInstance();
            ObservableCollection <Pointel.Interactions.Contact.Helpers.Attribute> contactList = new ObservableCollection <Helpers.Attribute>();

            TempOldContact = new List <Helpers.Attribute>();
            foreach (string displaAttributeName in ContactDataContext.GetInstance().ContactDisplayedAttributes)
            {
                if (!contactContext.ContactValidAttribute.Keys.Contains(displaAttributeName))
                {
                    continue;
                }
                #region Attribute not null
                if (attribute != null)
                {
                    List <AttributesHeader> displayAttributeList = attribute.Cast <AttributesHeader>().Where(x => x.AttrName == displaAttributeName).ToList <AttributesHeader>();
                    if (displayAttributeList.Count > 0)
                    {
                        //List<string> multipleitems = ((string)ConfigContainer.Instance().GetValue("contact.multiple-value-attributes")).Split(',').ToList();
                        foreach (AttributesHeader attr in displayAttributeList)
                        {
                            //for multivalue attribute
                            if (ContactDataContext.GetInstance().ContactMultipleValueAttributes.Contains(attr.AttrName))
                            {
                                for (int j = 0; j < attr.AttributesInfoList.Count; j++)
                                {
                                    Helpers.Attribute contactDetails = new Helpers.Attribute();

                                    contactDetails.AttributeId = attr.AttributesInfoList[j].AttrId;
                                    //contactDetails.AttributeName = attr.AttrName;
                                    contactDetails.AttributeName  = contactContext.ContactValidAttribute[attr.AttrName];
                                    contactDetails.AttributeValue = attr.AttributesInfoList[j].AttrValue.ToString();
                                    contactDetails.Description    = attr.AttributesInfoList[j].Description;
                                    contactDetails.Type           = Settings.ContactDataContext.AttributeType.Multiple;
                                    contactDetails.IsMandatory    = ContactDataContext.GetInstance().ContactMandatoryAttributes.Contains(attr.AttrName);
                                    //check whether the data is primary or not.
                                    contactDetails.Isprimary = attr.AttributesInfoList.Primary.AttrId == contactDetails.AttributeId;
                                    contactList.Add(contactDetails);
                                    AddToTempList(contactDetails);
                                }
                            }
                            //For single value attribute
                            else
                            {
                                Helpers.Attribute contactDetails = new Helpers.Attribute();
                                contactDetails.AttributeId = attr.AttributesInfoList[0].AttrId;
                                //contactDetails.AttributeName = attr.AttrName;
                                contactDetails.AttributeName  = contactContext.ContactValidAttribute[attr.AttrName];
                                contactDetails.AttributeValue = attr.AttributesInfoList[0].AttrValue.ToString();
                                contactDetails.Description    = attr.AttributesInfoList[0].Description;
                                contactDetails.Isprimary      = attr.AttributesInfoList.Primary.AttrId == contactDetails.AttributeId;
                                contactDetails.IsMandatory    = ContactDataContext.GetInstance().ContactMandatoryAttributes.Contains(attr.AttrName);
                                contactList.Add(contactDetails);
                                AddToTempList(contactDetails);
                            }
                        }
                    }
                    else
                    {
                        Helpers.Attribute contactDetails = new Helpers.Attribute();
                        // contactDetails.AttributeName = displaAttributeName;
                        contactDetails.AttributeName  = contactContext.ContactValidAttribute[displaAttributeName];
                        contactDetails.AttributeValue = string.Empty;
                        contactDetails.Description    = string.Empty;
                        //List<string> items = ((string)ConfigContainer.Instance().GetValue("contact.multiple-value-attributes")).Split(',').ToList();
                        if (ContactDataContext.GetInstance().ContactMultipleValueAttributes.Contains(displaAttributeName))
                        {
                            contactDetails.Type = Settings.ContactDataContext.AttributeType.Multiple;
                        }
                        contactList.Add(contactDetails);
                        AddToTempList(contactDetails);
                    }
                }
                #endregion Attribute not null
                else
                {
                    Helpers.Attribute contactDetails = new Helpers.Attribute();

                    //contactDetails.AttributeName = displaAttributeName;
                    contactDetails.AttributeName  = contactContext.ContactValidAttribute[displaAttributeName];
                    contactDetails.AttributeValue = string.Empty;
                    contactDetails.Description    = string.Empty;
                    contactDetails.IsMandatory    = ContactDataContext.GetInstance().ContactMandatoryAttributes.Contains(displaAttributeName);
                    // List<string> multipleItem = ((string)ConfigContainer.Instance().GetValue("contact.multiple-value-attributes")).Split(',').ToList();
                    if (ContactDataContext.GetInstance().ContactMultipleValueAttributes.Contains(displaAttributeName))
                    {
                        contactDetails.Type      = Settings.ContactDataContext.AttributeType.Multiple;
                        contactDetails.Isprimary = false;
                    }
                    else
                    {
                        contactDetails.Isprimary = true;
                    }

                    contactList.Add(contactDetails);
                    AddToTempList(contactDetails);
                }
            }
            return(contactList);
        }