Esempio n. 1
0
 public void UpdateContact(string id, Contact contact)
 {
     contact.Id = id;
     lock (syncRoot)
     {
         int index = this.FetchContact(id);
         if (index >= 0)
         {
             AllContacts[index] = contact;
         }
     }
 }
Esempio n. 2
0
        public string AddContact(Contact contact)
        {
            int contactId = Interlocked.Increment(ref currentId);
            contact.Id = contactId.ToString(CultureInfo.InvariantCulture);
            lock (syncRoot)
            {
                AllContacts.Add(contact);
                WebOperationContext.Current.OutgoingResponse.StatusCode = HttpStatusCode.Created;
            }

            return contact.Id;
        }