public bool Add(Contact contact) { try { contacts.Add(contact); } catch { return false; } return true; }
public bool Put(Contact contact) { Contact oldContact = contacts.SingleOrDefault(u => Convert.ToInt32(u.Id) == Convert.ToInt32(contact.Id)); if (oldContact == null) { try { contacts.Add(contact); } catch { return false; } return true; } else { contacts.Remove(oldContact); contacts.Add(contact); return true; } }