/// <summary>
 /// Get the OwnerPartyId for Contact
 /// </summary>
 /// <param name="partyId"></param>
 /// <returns></returns>
 public long? GetOwnerPartyIdForContact(long? partyId)
 {
     IContactService contactService = ContactService.GetService();
     ContactModel contactModel = new ContactModel();
     contactModel.PartyId = (long)partyId;
     ContactModel contactModelResult = contactService.GetOwnerPartyId(contactModel);
     return contactModelResult.OwnerPartyId;
 }
        /// <summary>
        /// Get the OwnerPartyId
        /// </summary>
        /// <param name="contactModel">ContactModel</param>
        /// <returns></returns>
        public ContactModel GetOwnerPartyId(ContactModel contactModel)
        {
            ContactModel resultModel = null;
            if (contactModel != null)
            {
                try
                {
                    DataObjectResult dataObjResult = _contactService._contactClient.getContact(contactModel.PartyId);
                    if (null == dataObjResult)
                    {
                        _logger.Debug("No Contact found matching external reference " + contactModel.PartyId);
                        resultModel = new ContactModel();
                        resultModel.OwnerPartyId = null;
                        return resultModel;
                    }
                    object[] dataObjResultValue = dataObjResult.Value;


                    foreach (object value in dataObjResultValue)
                    {
                        resultModel = new ContactModel();
                        Contact contact = (Contact) value;
                        resultModel.OwnerPartyId = (long) contact.OwnerPartyId;
                    }
                }
                catch (Exception e)
                {
                    _logger.Debug("Error occured while creating lead. Lead Not Created in Sales Cloud. Exception: " + e.StackTrace);
                    _logger.Debug("Setting OwnerPartyId for Contact to null");
                    resultModel = new ContactModel();
                    resultModel.OwnerPartyId = null;
                }
            }

            return resultModel;
        }