예제 #1
0
        public bool Add(Contact contact)
        {
            try
            {

                contacts.Add(contact);
            }
            catch
            {
                return false;
            }
            return true;
        }
예제 #2
0
        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;
            }
        }