Exemple #1
0
 public void UpdateFrom(Contact contact)
 {
     Name = string.IsNullOrEmpty(contact.Name) ? Name : contact.Name;
     Gender = contact.Gender;
     DateOfBirth = contact.DateOfBirth == DateTime.MinValue ? DateOfBirth : contact.DateOfBirth;
     Email = string.IsNullOrEmpty(contact.Email) ? Email : contact.Email;
 }
 public void UpdateContact(int contactId, Contact contact)
 {
     var existing = GetContact(contactId);
     existing.UpdateFrom(contact);
 }
 public void AddContact(Contact contact)
 {
     SaveContact(contact);
 }
 public void SaveContact(Contact contact)
 {
     if (contact.Id <= 0)
     {
         contact.Id = _contactIdSequence++;
     }
     lock (_contacts)
     {
         if (_contacts.Count > MaxItems)
             throw new AppException("Too many contacts. Please delete some.");
         _contacts[contact.Id] = contact;
     }
 }