public void ReassignAccountToExistingAccount(int accountId, PersonInfo fromPerson, PersonInfo toPerson)
        {
            Debug.Assert(fromPerson != null);
            Debug.Assert(toPerson != null);
            if (fromPerson.PersonId == toPerson.PersonId)
                return;
            lock (_lockObj) {
                fromPerson.RemoveAccount(accountId);
                toPerson.AddAccount(accountId);

                _accountIdToPersonId[accountId] = toPerson.PersonId;
                SQLSetPersonId(accountId, toPerson.PersonId);

                // update person info based on account type
                EAccountType accountType = GetAccountType(accountId);

                // if the fromPerson has no more email contacts then we remove the reference to the fromPerson
                bool noMoreAccounts = (fromPerson.GetAccountIds().Count() == 0);
                if (noMoreAccounts) {
                    _personIdToPerson.Remove(fromPerson.PersonId);
                    SQLRemovePerson(fromPerson.PersonId);
                }
            }
        }
 public int GetPersonTotalToCount(PersonInfo person)
 {
     if (person == null) return 0;
     int tot = 0;
     foreach (int id in person.GetAccountIds())
         tot += GetEmailToCount(id);
     return tot;
 }
 public void MergePersons(PersonInfo fromPerson, PersonInfo toPerson)
 {
     Debug.Assert(fromPerson != null);
     Debug.Assert(toPerson != null);
     foreach (int id in fromPerson.GetAccountIds())
         ReassignAccountToExistingAccount(id, fromPerson, toPerson);
     lock (_lockObj) {
         toPerson.CopyDataFromContact(fromPerson);
     }
 }
 public int GetPersonTotalFromToCount(PersonInfo fromPerson, PersonInfo toPerson)
 {
     if (fromPerson == null) return 0;
     if (toPerson == null) return 0;
     int tot = 0;
     foreach (int e1 in fromPerson.GetAccountIds())
         foreach (int e2 in toPerson.GetAccountIds())
             tot += GetEmailFromToCount(e1, e2);
     return tot;
 }