internal Response <AccountDetails> CheckBankAccountDetails(int issuerId, int productId, int branchId, string accountNumber, decimal amount, long auditUserId, string auditWorkstation, int languageId, int cardIssueReasonId)
        {
            var auditInfo = new AuditInfo
            {
                AuditUserId      = auditUserId,
                AuditWorkStation = auditWorkstation,
                LanguageId       = languageId
            };
            IntegrationController _integration = IntegrationController.Instance;
            var accountLookupLogic             = new Logic.AccountLookupLogic(_cardManService, _comsCore, _integration);

            // Do CBS Lookup
            var cbsResponse = accountLookupLogic.CoreBankingAccountLookupFundsLoad(issuerId, productId, cardIssueReasonId, branchId, accountNumber, auditInfo);

            if (cbsResponse.ResponseType == ResponseType.SUCCESSFUL)
            {
                string responseMessage;
                log.Trace(t => t("cbsResponse.ResponseType == ResponseType.SUCCESSFUL"));

                log.Trace(t => t("CardManagementAccountLookup = True"));
                var balanceResponse = CheckBalance(cbsResponse, issuerId, productId, branchId, languageId, amount, auditUserId, auditWorkstation, accountNumber, out responseMessage);
                if (balanceResponse == true)
                {
                    return(cbsResponse);
                }
                else
                {
                    log.Trace(responseMessage);
                }

                return(new Response <AccountDetails>(null, ResponseType.UNSUCCESSFUL, responseMessage, String.Empty));
            }
            return(cbsResponse);
        }
        private bool ExecuteFundsLoad(long id, long auditUserId, string auditWorkstation, int languageId, int cardIssueReasonId)
        {
            try
            {
                var fundsLoad = _fundsOperations.Retrieve(id, false, auditUserId, auditWorkstation);
                var auditInfo = new AuditInfo
                {
                    AuditUserId      = auditUserId,
                    AuditWorkStation = auditWorkstation,
                    LanguageId       = languageId
                };
                IntegrationController _integration = IntegrationController.Instance;
                var accountLookupLogic             = new Logic.AccountLookupLogic(_cardManService, _comsCore, _integration);
                log.Trace(t => t("ExecuteFundsLoad: CoreBankingAccountLookup"));
                var    cbsResponse = accountLookupLogic.CoreBankingAccountLookup(fundsLoad.IssuerId, fundsLoad.ProductId, cardIssueReasonId, fundsLoad.BranchId, fundsLoad.BankAccountNo, auditInfo);
                string responseMessage;

                if (cbsResponse.ResponseType == ResponseType.SUCCESSFUL)
                {
                    log.Trace(t => t("cbsResponse.ResponseType == ResponseType.SUCCESSFUL"));
                    CustomerDetails customerDetails = ExtractCustomerFromAccount(cbsResponse, fundsLoad.BranchId, fundsLoad.ProductId, fundsLoad.IssuerId, fundsLoad.Amount);
                    customerDetails.AccountNumber = fundsLoad.BankAccountNo;
                    customerDetails.FeeCharge     = fundsLoad.Amount;
                    customerDetails.TotalCharged  = fundsLoad.Amount;

                    bool accountLegDone = ExecuteBankAccountDebit(fundsLoad, customerDetails, auditUserId, auditWorkstation, languageId);
                    bool prepaidLegDone = false;
                    if (accountLegDone)
                    {
                        log.Trace(t => t("Account Leg Done"));
                        prepaidLegDone = ExecutePrepaidAccountCredit(fundsLoad);
                        if (prepaidLegDone)
                        {
                            log.Trace(t => t("Prepaid Leg Done"));
                            return(true);
                        }
                        else
                        {
                            //reverse the transaction to the main account
                            fundsLoad.Amount             = fundsLoad.Amount * -1;
                            customerDetails.TotalCharged = fundsLoad.Amount;

                            ExecuteBankAccountDebit(fundsLoad, customerDetails, auditUserId, auditWorkstation, languageId);
                            return(false);
                        }
                    }
                    else
                    {
                        log.Trace($"Account Leg Failed");
                    }
                }
                else
                {
                    log.Trace($"ExecuteFundLoad:cbsResponse.ResponseType <> ResponseType.SUCCESSFUL Actual Value is {cbsResponse.ResponseType} with message {cbsResponse.ResponseMessage}");
                    return(false);
                }
            }
            catch (Exception exp)
            {
                log.Error($"An exception occurred : { exp.Message}");
                return(false);
            }
            return(false);
        }