private void AddContacts(ContactGroupOwner owner, Contact[] clientContacts) { var generalGroup = owner.AddContactGroup(ContactGroupType.General); foreach (var contact in clientContacts) { if (contact.ContactText != null) { generalGroup.AddContact(contact); } } DbSession.Save(owner); }
public virtual void Init(Administrator admin) { Registration = new RegistrationInfo(admin); if (ContactGroupOwner == null) { ContactGroupOwner = new ContactGroupOwner(); } if (!ContactGroupOwner.HaveGroup(ContactGroupType.Billing)) { ContactGroupOwner.AddContactGroup(ContactGroupType.Billing); } }
public virtual void MergePerson(ContactGroupType type, Person person) { var group = ContactGroupOwner.ContactGroups.FirstOrDefault(g => g.Type == type) ?? ContactGroupOwner.AddContactGroup(type); var exists = group.Persons.FirstOrDefault(p => String.Equals(p.Name, person.Name, StringComparison.CurrentCultureIgnoreCase)); if (exists == null) { group.Persons.Add(person); group.Adopt(); } else { foreach (var contact in person.Contacts) { if (!exists.Contacts.Any(c => c.Type == contact.Type && String.Equals(contact.ContactText, c.ContactText, StringComparison.CurrentCultureIgnoreCase))) { exists.AddContact(new Contact(contact.Type, contact.ContactText, contact.Comment)); } } } }