Ejemplo n.º 1
0
        public Response <AccountDetails> CoreBankingAccountLookupFundsLoad(int issuerId, int productId, int cardIssueReasonId, int branchId, string accountNumber, AuditInfo auditInfo)
        {
            _log.Trace(t => t("Looking up account in Core Banking System."));

            //Find printer fields for product
            List <IProductPrintField> printFields = _cardManService.GetProductPrintFields(productId, null, null);

            // Get configuration and external fields for product
            Veneka.Indigo.Integration.Config.IConfig config;
            ExternalSystemFields externalFields;

            _integration.FundsLoadCoreBankingSystem(productId, out externalFields, out config);

            InterfaceInfo interfaceInfo = new InterfaceInfo
            {
                Config        = config,
                InterfaceGuid = config.InterfaceGuid.ToString()
            };

            CardObject _object = new CardObject
            {
                CustomerAccount = new AccountDetails
                {
                    AccountNumber = accountNumber
                },
                PrintFields = printFields,
            };

            _log.Debug("calling GetAccountDetail");

            var cbsResponse = _comsCore.GetAccountDetail(_object, cardIssueReasonId, issuerId, branchId, productId, externalFields, interfaceInfo, auditInfo);

            if (cbsResponse.ResponseCode == 0)
            {
                // Sanity check that integration has actually returned an AccountDetails Object
                if (cbsResponse.Value == null)
                {
                    throw new Exception("Core Banking Interface responded successfuly but AccountDetail is null.");
                }

                //Check that the integration layer sent back the productFields
                if (cbsResponse.Value.ProductFields == null || cbsResponse.Value.ProductFields.Count < printFields.Count)
                {
                    throw new Exception("Integration layer has not returned all Product Print Fields.");
                }

                _log.Trace(t => t("Account successfully found in Core Banking System."));
                var accountDetails = cbsResponse.Value;

                // Do account mapping.
                // get the cms acconttype ,indigo_accountypte from account mapping assing to cardobject.
                ProductAccountTypeMapping mapping;
                if (_cardManService.TryGetProductAccountTypeMapping(productId, accountDetails.CBSAccountTypeId, auditInfo.LanguageId, auditInfo.AuditUserId, auditInfo.AuditWorkStation, out mapping))
                {
                    _log.Trace(t => t("CBS account mapping found"));
                    accountDetails.CMSAccountTypeId = mapping.CmsAccountType;
                    accountDetails.AccountTypeId    = mapping.IndigoAccountTypeId;
                }
                else
                {
                    throw new Exception(string.Format("No mapping found for product {0} and CBS Account Type {1}", productId, accountDetails.CBSAccountTypeId));
                }

                // Name on card build
                try
                {
                    //Logic for name on card if the filed is not populated, if it is populated then ignore integration layer handled it
                    IProductPrintField obj = printFields.Find(i => i.MappedName.Trim().ToUpper() == "IND_SYS_NOC");
                    if (String.IsNullOrWhiteSpace(accountDetails.NameOnCard) && obj != null)
                    {
                        accountDetails.NameOnCard = Veneka.Indigo.Integration.Common.Utility.BuildNameOnCard(accountDetails.FirstName, accountDetails.MiddleName, accountDetails.LastName);
                    }
                }
                catch (Exception ex)
                {
                    _log.Warn("Issue building name on card.", ex);
                }

                return(new Response <AccountDetails>(accountDetails, ResponseType.SUCCESSFUL, cbsResponse.ResponseMessage, ""));
            }

            return(new Response <AccountDetails>(null, ResponseType.UNSUCCESSFUL, cbsResponse.ResponseMessage, ""));
        }