/// <summary>
 /// Get the OwnerPartyId
 /// </summary>
 /// <param name="partyId"></param>
 /// <returns></returns>
 public long? GetOwnerPartyId(long? partyId)
 {
     IAccountService accountService = AccountService.GetService();
     AccountModel accountModel = new AccountModel();
     accountModel.PartyId = (long)partyId;
     AccountModel accountModelResult = accountService.GetOwnerPartyId(accountModel);
     return accountModelResult.OwnerPartyId;
 }
        /// <summary>
        /// Get the OwnerPartyId
        /// </summary>
        /// <param name="accountModel">AccountModel</param>
        /// <returns></returns>
        public AccountModel GetOwnerPartyId(AccountModel accountModel)
        {
            AccountModel resultModel = null;
            if (accountModel != null)
            {
                try
                {
                    DataObjectResult dataObjResult = _accountService._accountClient.getAccount(accountModel.PartyId);
                    if (null == dataObjResult)
                    {
                        _logger.Debug("No Account found matching external reference " + accountModel.PartyId);
                        resultModel = new AccountModel();
                        resultModel.OwnerPartyId = null;
                        return resultModel;
                    }
                    object[] dataObjResultValue = dataObjResult.Value;


                    foreach (object value in dataObjResultValue)
                    {
                        resultModel = new AccountModel();
                        Account account = (Account) value;
                        resultModel.OwnerPartyId = (long) account.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 Account to null");
                    resultModel = new AccountModel();
                    resultModel.OwnerPartyId = null;
                }
            }

            return resultModel;
        }