public void UpdateContact(string id, Contact contact) { contact.Id = id; lock (syncRoot) { int index = this.FetchContact(id); if (index >= 0) { AllContacts[index] = contact; } } }
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; }