Esempio n. 1
0
        private ICollection <PhoneContactTags> updateContactTags(List <Dictionary <string, string> > contactTags, PhoneContact phoneContact)
        {
            this.deleteContactTags(phoneContact);
            ICollection <ContactTag> newContactTags = new HashSet <ContactTag>();

            foreach (Dictionary <string, string> contactTag in contactTags)
            {
                ContactTag dbContactTag = _contantTagRepo.findOneBy(c => c.tag.ToString().ToLower().Equals(contactTag["value"].ToLower()));
                if (dbContactTag == null)
                {
                    dbContactTag     = new ContactTag();
                    dbContactTag.tag = contactTag["value"];
                    _contantTagRepo.Create(dbContactTag);
                    _contantTagRepo.Save();
                    newContactTags.Add(dbContactTag);
                    continue;
                }

                if (dbContactTag != null && !phoneContact.contactContainsTag(dbContactTag))
                {
                    newContactTags.Add(dbContactTag);
                }
            }
            return(this.createPhoneContactTags(newContactTags, phoneContact));
        }
Esempio n. 2
0
        private ICollection <PhoneContactTags> createContactTags(List <Dictionary <string, string> > contactTags, PhoneContact phoneContact)
        {
            ICollection <ContactTag> contactTagEntities = new List <ContactTag>();

            foreach (Dictionary <string, string> conTag in contactTags)
            {
                ContactTag dbContantTag = _contantTagRepo.findOneBy(c => c.tag.ToString().Equals(conTag["value"]));
                if (phoneContact.contactContainsTag(dbContantTag))
                {
                    continue;
                }

                if (dbContantTag == null)
                {
                    dbContantTag     = new ContactTag();
                    dbContantTag.tag = conTag["value"];
                    _contantTagRepo.Create(dbContantTag);
                    _contantTagRepo.Save();
                }
                contactTagEntities.Add(dbContantTag);
            }
            return(this.createPhoneContactTags(contactTagEntities, phoneContact));
        }