public IActionResult ApprovePaymentOrder(ApproveIdRequest request)
        {
            if (ModelState.IsValid)
            {
                SingleResponse <long> response   = new SingleResponse <long>();
                PaymentOrder          order      = _cacheHelper.GetApprovalOrder <PaymentOrder>(request.Id);
                XBS.ActionResult      saveResult = _xBService.ApprovePaymentOrder(order);

                response.ResultCode  = ResultCodeFormatter.FromPersonalAccountSecurityService(saveResult.ResultCode);
                response.Result      = saveResult.Id;
                response.Description = Utils.GetActionResultErrors(saveResult.Errors);

                return(ResponseExtensions.ToHttpResponse(response));
            }
            else
            {
                return(ValidationError.GetValidationErrorResponse(ModelState));
            }
        }
        private SingleResponse <long> SaveAttachedCardOrder(AttachCardBindingRequest request)
        {
            SingleResponse <long> response = new SingleResponse <long>()
            {
                ResultCode = ResultCodes.normal
            };

            XBS.ActionResult result = new XBS.ActionResult();
            //Տարանցիկ հաշվի ստացում դեբետագրելու համար , կախված հայտի տեսակից
            string accountNumber = _client.GetMerchantAccountNumberByOrderType(new AttachedCardOrderTypeRequest
            {
                Currency     = GetOrderTypeBasedCurrency(request),
                OrderType    = (int)request.Order.Type,
                OrderSubType = request.Order.SubType
            })?.AccountNumber;

            if (string.IsNullOrEmpty(accountNumber))
            {
                response.ResultCode = ResultCodes.failed;
                return(response);
            }
            switch (request.Order.Type)
            {
            case OrderType.RATransfer:
            {
                if (request.Order.SubType == 3)
                {
                    PaymentOrder order = new PaymentOrder
                    {
                        Amount           = request.Order.Amount,
                        Currency         = request.Order.Currency,
                        SubType          = request.Order.SubType,
                        Type             = request.Order.Type,
                        ReceiverBankCode = request.Order.ReceiverBankCode,
                        ReceiverAccount  = new Account
                        {
                            AccountNumber = request.Order.ReceiverAccount.AccountNumber,
                            Currency      = request.Order.ReceiverAccount.Currency
                        },
                        DebitAccount = new Account
                        {
                            AccountNumber  = accountNumber,
                            Currency       = request.Order.DebitAccount.Currency,
                            IsAttachedCard = true
                        }
                    };
                    result = _xBService.SavePaymentOrder(order);
                }
                //else if (request.Order.SubType == 6)
                //{
                //    BudgetPaymentOrder order = new BudgetPaymentOrder
                //    {
                //        Amount = request.Order.Amount,
                //        Currency = request.Order.Currency,
                //        SubType = request.Order.SubType,
                //        Type = request.Order.Type,
                //        ReceiverBankCode = request.Order.ReceiverBankCode,
                //        UseCreditLine = request.Order.UseCreditLine,
                //        Description = request.Order.Description,
                //        TransferFee = request.Order.TransferFee,
                //        Receiver = request.Order.Receiver,
                //        PoliceResponseDetailsId = request.Order.PoliceResponseDetailsId,
                //        LTACode = request.Order.LTACode,
                //        FeeAccount = new Account
                //        {
                //            AccountNumber = request.Order.FeeAccount.AccountNumber,
                //            Currency = request.Order.FeeAccount.Currency
                //        },
                //        ReceiverAccount = new Account
                //        {
                //            AccountNumber = request.Order.ReceiverAccount.AccountNumber
                //        },
                //        DebitAccount = new Account
                //        {
                //            AccountNumber = accountNumber,
                //            Currency = request.Order.DebitAccount.Currency,
                //            IsAttachedCard = true
                //        }
                //    };
                //    result = _xBService.SaveBudgetPaymentOrder(order);
                //}
            }
            break;

            case OrderType.LoanMature:
            {
                string loanAccNumber = _xBService.GetLiabilitiesAccountNumberByAppId(request.Order.ProductId);
                if (string.IsNullOrEmpty(loanAccNumber))
                {
                    response.ResultCode = ResultCodes.failed;
                    return(response);
                }
                PaymentOrder order = new PaymentOrder
                {
                    Amount           = request.Order.Amount,
                    Currency         = request.Order.Currency,
                    SubType          = 3,
                    Type             = OrderType.RATransfer,
                    ReceiverBankCode = request.Order.ReceiverBankCode,
                    ReceiverAccount  = new Account
                    {
                        AccountNumber = loanAccNumber,
                        Currency      = request.Order.Currency
                    },
                    DebitAccount = new Account
                    {
                        AccountNumber  = accountNumber,
                        Currency       = request.Order.Currency,
                        IsAttachedCard = true
                    }
                };
                result = _xBService.SavePaymentOrder(order);
                if (result.ResultCode == ResultCode.Normal)
                {
                    PaymentOrder paymOrder = _xBService.GetPaymentOrder(result.Id);
                    result = _xBService.ApprovePaymentOrder(paymOrder);
                    if (result.ResultCode == ResultCode.Normal)
                    {
                        MatureOrder matureOrder = new MatureOrder
                        {
                            ProductId  = request.Order.ProductId,
                            Amount     = request.Order.Amount,
                            Currency   = request.Order.Currency,
                            SubType    = request.Order.SubType,
                            Type       = request.Order.Type,
                            MatureType = request.Order.MatureType,
                            MatureMode = request.Order.MatureMode,
                            Account    = new Account
                            {
                                AccountNumber  = loanAccNumber,
                                Currency       = request.Order.Currency,
                                IsAttachedCard = true
                            }
                        };
                        result = _xBService.SaveMatureOrder(matureOrder);
                    }
                }
            }
            break;

            case OrderType.CommunalPayment:
            {
                UtilityPaymentOrder order = new UtilityPaymentOrder
                {
                    Amount            = request.Order.Amount,
                    Currency          = request.Order.Currency,
                    Type              = request.Order.Type,
                    Code              = request.Order.Code,
                    AbonentType       = request.Order.AbonentType,
                    CommunalType      = request.Order.CommunalType,
                    Branch            = request.Order.Branch,
                    AbonentFilialCode = request.Order.AbonentFilialCode,
                    PaymentType       = request.Order.PaymentType,
                    DebitAccount      = new Account
                    {
                        AccountNumber  = accountNumber,
                        Currency       = "AMD",
                        IsAttachedCard = true
                    }
                };
                result = _xBService.SaveUtilityPaymentOrder(order);
            }
            break;

            default:
                break;
            }
            response.Result      = result.Id;
            response.ResultCode  = ResultCodeFormatter.FromPersonalAccountSecurityService(result.ResultCode);
            response.Description = Utils.GetActionResultErrors(result.Errors);
            return(response);
        }