BusinessComponents.OperationsComponent.UpdateExistingContact C# (CSharp) Method

UpdateExistingContact() public static method

Method used for updating an existing contact
public static UpdateExistingContact ( CredentialsDetails credentialsDetails, ContactDetails contact, string &strRequest, string &strResponse ) : void
credentialsDetails BusinessObjects.CredentialsDetails An object that encapsulates the Constant Contact credentials
contact BusinessObjects.ContactDetails The contact url
strRequest string The request string representation
strResponse string The response string representation
return void
        public static void UpdateExistingContact(CredentialsDetails credentialsDetails, ContactDetails contact, out string strRequest, out string strResponse)
        {
            string req;
            string res;

            //Get the contact data
            var xmlContact = ApiCallComponent.CallServiceGet(credentialsDetails, contact.Id, out req, out res);

            //Update the contact data
            var xContact = XDocument.Parse(xmlContact);
            var contactNode = (from f in xContact.Descendants(W3Ns + "content")
                               let element = f.Element(ConstantContactNs + "Contact")
                               where element != null
                               select element).FirstOrDefault();

            if (contactNode != null)
            {
                contactNode.SetElementValue(ConstantContactNs + "FirstName", contact.FirstName);
                contactNode.SetElementValue(ConstantContactNs + "LastName", contact.LastName);
            }

            //Put the updated contact data
            ApiCallComponent.CallServicePut(credentialsDetails, contact.Id, xContact.Declaration.ToString() + xContact, out strRequest, out strResponse);
        }