예제 #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;
 }
예제 #2
0
 public void UpdateContact(int contactId, Contact contact)
 {
     var existing = GetContact(contactId);
     existing.UpdateFrom(contact);
 }
예제 #3
0
 public void AddContact(Contact contact)
 {
     SaveContact(contact);
 }
예제 #4
0
 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;
     }
 }