public string GetPacs008(Pacs008DTO pacs008DTO)
        {

            string response = string.Empty;
            try
            {
                if (pacs008DTO != null)
                {
                    string otherData = string.Empty;

                    /*otherData = "<BillInfo>"+pacs008DTO.BillInfo + "</BillInfo>" +"+"+ "<EntityName>" + pacs008DTO.EntityName + "</EntityName>" + "+" + "<MobileNumber>" + pacs008DTO.MobileNumber + "</MobileNumber>"
                        + "+" + "<LatLong>" + pacs008DTO.LatLong + "</LatLong>"+ "+" + "<Location>" + pacs008DTO.Location+ "</Location>" + "+" + "<IP>" +pacs008DTO.IP + "</IP>" + "+" + "<IEMEIID>" + pacs008DTO.IEMEIID + "</IEMEIID>"
                        + "+" +"<OS>" + pacs008DTO.OS + "</OS>" + "+" + "<App>" + pacs008DTO.App + "</App>" + "+" + "<Capability>" + pacs008DTO.Capability+ "</Capability>";*/
                    /*otherData = pacs008DTO.BillInfo + "-" + pacs008DTO.EntityName + "-" + pacs008DTO.MobileNumber + "-" + pacs008DTO.LatLong + "-" + pacs008DTO.Location + "-" + pacs008DTO.IP
                        + "-" + pacs008DTO.IEMEIID + "-" + pacs008DTO.OS + "-" + pacs008DTO.App + "-" + pacs008DTO.Capability;*/
                    /*otherData ="Bill " +pacs008DTO.BillInfo + "-Entity " + pacs008DTO.EntityName + "-Cell " + pacs008DTO.MobileNumber + "-Latlong " + pacs008DTO.LatLong + "-Location " + pacs008DTO.Location + "-IP" + pacs008DTO.IP
                        + "-" + pacs008DTO.IEMEIID + "-OS " + pacs008DTO.OS + "-App " + pacs008DTO.App + "-Capability " + pacs008DTO.Capability;*/

                    otherData = "BillNo:" + pacs008DTO.BillInfo + ", Cell:" + pacs008DTO.MobileNumber + ", Purpose:" + pacs008DTO.PaymentPurpose;
                    int length = otherData.Length;

                    if (length >= 140)
                    {
                        otherData = otherData.Substring(0, 139);
                    }

                    //ISOComposer composer = new ISOComposer();
                    XmlDocument xmlDocument = ISOComposer.GetPacs008Data(pacs008DTO.SenderBankBIC, pacs008DTO.ReceiverBankBIC, pacs008DTO.SenderName, pacs008DTO.ReceiverName, pacs008DTO.TransactionId,
                        pacs008DTO.SenderAccount, pacs008DTO.SenderBranchRoutingNo, pacs008DTO.SendingBankCBAccount, pacs008DTO.ReceiverBranchRoutingNo, pacs008DTO.ReceivingBankCBAccount,
                        pacs008DTO.ReceiverAccount, pacs008DTO.Amount, otherData);
                    response = xmlDocument.InnerXml.ToString();
                }
                return response;
            }

            catch (Exception)
            {
                response = IDTPXmlParser.PrepareFailResponse("Pacs008");
                return response;
            }

        }
        public async Task <IActionResult> Create([FromForm] TransactionBillDTO tbd)
        {
            // creating object of CultureInfo
            try
            {
                CultureInfo cultures = new CultureInfo("en-US");

                if (tbd != null)
                {
                    #region fetch data db
                    var sender = _businessLayer.GetAllBankUsers().Where(u => u.AccountNumber == tbd.SenderAccNo).FirstOrDefault();
                    if (sender == null)
                    {
                        TempData["error"] = "User Not Found";
                        return(RedirectToAction(nameof(Index)));
                    }
                    var SenderBank   = _businessLayer.GetAllBanks().Where(b => b.Id == tbd.SenderBankId).FirstOrDefault();
                    var senderBranch = _businessLayer.GetAllBranchs().Where(br => br.Id == tbd.SenderBranchId).FirstOrDefault();
                    #endregion
                    var senderBankRoutingNo = senderBranch.RoutingNumber;
                    //var receiverBankRoutingNo = receiverBranch.RoutingNumber;
                    var transactionId = SenderBank.SwiftBic.Substring(0, 4) + DateTime.Now.ToString("yyyyMMddHHmmss", cultures);

                    #region create pacs008 xml
                    //ISOComposer composer = new ISOComposer();
                    var pacs008xml = ISOComposer.GetPacs008Data(SenderBank.SwiftBic, "", sender.AccountName, tbd.ReceiverName, transactionId, tbd.SenderAccNo,
                                                                senderBankRoutingNo, SenderBank.CbaccountNo, "", "", "", tbd.Amount.ToString(), "Bill Payment");
                    #endregion

                    #region fetch data db
                    sender.Balance    -= tbd.Amount;
                    sender.EntityState = EntityState.Modified;
                    _businessLayer.UpdateBankUser(sender);
                    #endregion

                    #region get token for session
                    //login as user
                    LoginDTO loginDTO = new LoginDTO
                    {
                        UserName    = Helper.Constants.UserName,
                        MasterToken = Helper.Constants.UserSecret
                    };
                    //get token
                    string token = await HttpClientAuthorization.GetAuthorizationToken(loginDTO);

                    HttpContext.Session.SetString("token", token);
                    #endregion

                    TransactionRequestLog        transactionRequestLog        = new TransactionRequestLog();
                    TransactionRequestLog        transactionRequestLogReceive = new TransactionRequestLog();
                    List <TransactionRequestLog> logs = new List <TransactionRequestLog>();
                    var responseResult = string.Empty;
                    //Uri uri = new Uri("https://localhost:44321/TransactionBill");
                    //var uri = "https://idtp-fundtransfer.azurewebsites.net/TransactionBill";
                    var uri = new Uri(Helper.Constants.IDTPApiGatewayUrl + "ft/TransactionBill");
                    using (var client = new HttpClient())
                    {
                        transactionRequestLog.TransactionId  = transactionId;
                        transactionRequestLog.RequestFrom    = SenderBank.FinancialInstitution.InstitutionName;
                        transactionRequestLog.RequestTo      = "IDTP";
                        transactionRequestLog.RequestMessage = pacs008xml.InnerXml;
                        transactionRequestLog.RequestTime    = DateTime.Now;
                        transactionRequestLog.CreatedBy      = SenderBank.FinancialInstitution.InstitutionName;
                        transactionRequestLog.CreatedOn      = DateTime.Now;
                        transactionRequestLog.ModifiedBy     = SenderBank.FinancialInstitution.InstitutionName;
                        transactionRequestLog.ModifiedOn     = DateTime.Now;
                        transactionRequestLog.EntityState    = EntityState.Added;
                        logs.Add(transactionRequestLog);
                        //_businessLayer.AddTransactionRequestLog(transactionRequestLog);
                        //calling to IDTP API
                        responseResult = HttpClientHelper.Post(uri, pacs008xml.InnerXml, token);
                    }
                    responseResult = responseResult.Replace("\\", "", StringComparison.CurrentCulture);

                    responseResult = responseResult.Substring(1, responseResult.Length - 2);

                    transactionRequestLogReceive.TransactionId  = transactionId;
                    transactionRequestLogReceive.RequestFrom    = "IDTP";
                    transactionRequestLogReceive.RequestTo      = SenderBank.FinancialInstitution.InstitutionName;
                    transactionRequestLogReceive.RequestMessage = responseResult;
                    transactionRequestLogReceive.RequestTime    = DateTime.Now;
                    transactionRequestLogReceive.CreatedBy      = "IDTP";
                    transactionRequestLogReceive.CreatedOn      = DateTime.Now;
                    transactionRequestLogReceive.ModifiedBy     = "IDTP";
                    transactionRequestLogReceive.ModifiedOn     = DateTime.Now;
                    transactionRequestLogReceive.EntityState    = EntityState.Added;
                    logs.Add(transactionRequestLogReceive);
                    _businessLayer.AddTransactionRequestLog(logs.ToArray());
                    //responseResult = "<" + responseResult + ">";
                    XmlDocument doc = new XmlDocument();
                    doc.LoadXml(responseResult);
                    TempData["txnId"] = doc.GetElementsByTagName("OrgnlTxId").Item(0).InnerText;
                }

                return(RedirectToAction(nameof(Index)));
            }
            catch (Exception ex)
            {
                TempData["error"] = ex.Message;
                return(RedirectToAction(nameof(Index)));
            }
        }