コード例 #1
0
        /// <summary>
        /// Returns how many RAW is owned and how many have not yet been received by account.
        /// </summary>
        /// <param name="acc">The account to get balance for.</param>
        /// <returns>Balance of <paramref name="acc"/> in RAW.</returns>
        public async Task <BalanceResult> GetBalanceAsync(RaiAddress acc)
        {
            var action  = new GetBalance(acc);
            var handler = new ActionHandler <GetBalance, BalanceResult>(_node);

            return(await handler.Handle(action));
        }
コード例 #2
0
        public override async Task <SpeechletResponse> OnIntentAsync(IntentRequest intentRequest, Session session)
        {
            if (AlexaUtils.IsRequestInvalid(session))
            {
                return(await Task.FromResult <SpeechletResponse>(InvalidApplicationId(session)));
            }

            var intent     = intentRequest.Intent;
            var intentName = intent?.Name;

            switch (intentName.ToUpper())
            {
            case "BALANCE":
                return(await GetBalance.GetResults(session));

            case "TRANSACTIONS":
                return(await GetTransactions.GetResults(session, intentRequest.Intent.Slots["date"].Value));

            case "PAYMENT":
                return(await MakePayment.GetResults(session, decimal.Parse(intentRequest.Intent.Slots["amount"].Value), intentRequest.Intent.Slots["account"].Value));

            case "WINNERS":
                return(await Winners.GetResults());

            case "MORTGAGE":
                return(await Mortgage.GetResults(session));

            case "SAVINGS":
                return(await Insights.GetResults(session));

            default:
                return(await Task.FromResult <SpeechletResponse>(GetOnLaunchAsyncResult(session)));
            }
        }
コード例 #3
0
        async Task <GetBalanceResponse> ICommonGameActionsProvider.GetBalanceAsync(GetBalance request)
        {
            if (_useRealUgs)
            {
                var client = _flycowApiClientProvider.GetApiClient();
                var token  = await _flycowApiClientProvider.GetApiToken(client);

                var balanceResponse = await client.GetBalanceAsync(new GetBalanceRequest
                {
                    authtoken = request.AuthToken
                }, token);

                return(new GetBalanceResponse
                {
                    Balance = balanceResponse.bal,
                    CurrencyCode = balanceResponse.cur,
                });
            }

            var playerId = GetPlayerIdFromToken(request);
            var balance  = await _gameQueries.GetPlayableBalanceAsync(playerId);

            return(new GetBalanceResponse
            {
                Balance = balance.Balance,
                CurrencyCode = balance.CurrencyCode,
            });
        }
コード例 #4
0
ファイル: TestRPC.cs プロジェクト: Spl3en/IconSDK.Net
        public async Task Test_GetBalance()
        {
            var GetBalance = new GetBalance(API_URL);
            var balance    = await GetBalance.Invoke("hx0000000000000000000000000000000000000000");

            Console.WriteLine($"Treasury : {balance.ToString()}");
        }
コード例 #5
0
ファイル: TestRPC.cs プロジェクト: arkoc/IconSDK.Net
        public async Task Test_GetBalance2()
        {
            var getBalance = GetBalance.Create(Consts.ApiUrl.TestNet);
            var balance    = await getBalance("hx0000000000000000000000000000000000000000");

            Console.WriteLine($"Treasury : {balance.ToString()}");
        }
コード例 #6
0
        public static void DisplayBalance()
        {
            var wallet     = WalletHelper.LoadWallet();
            var getBalance = GetBalance.Create(WalletHelper.TestNetUrl);
            var balance    = getBalance.Invoke(wallet.Address).Result;

            Console.WriteLine($"Your current ICX balance for {wallet.Address} is : {Utils.Loop2ICX(balance)} ICX");
        }
コード例 #7
0
ファイル: TestRPC.cs プロジェクト: arkoc/IconSDK.Net
        public void Test_RPCMethodNotFoundException()
        {
            var getBalance = new GetBalance(Consts.ApiUrl.TestNet);

            GetBalanceRequestMessage requestMessage = new GetBalanceRequestMessage("hx0000000000000000000000000000000000000000");
            FieldInfo methodFieldInfo = typeof(GetBalanceRequestMessage).GetField("Method");

            methodFieldInfo.SetValue(requestMessage, "icx_GetBalance");  // 'icx_getBalance' is correct

            Assert.ThrowsAsync(typeof(RPCMethodNotFoundException), async() => await getBalance.Invoke(requestMessage));
        }
コード例 #8
0
        async Task <GetBalanceResponse> ICommonGameActionsProvider.GetBalanceAsync(GetBalance request)
        {
            var playerId = GetPlayerIdFromToken(request);
            var balance  = await _gameQueries.GetPlayableBalanceAsync(playerId);

            return(new GetBalanceResponse
            {
                Balance = balance.Balance,
                CurrencyCode = balance.CurrencyCode,
            });
        }
コード例 #9
0
ファイル: TestRPC.cs プロジェクト: arkoc/IconSDK.Net
        public void Test_RPCInvalidParamsException()
        {
            var getBalance = new GetBalance(Consts.ApiUrl.TestNet);

            GetBalanceRequestMessage requestMessage = new GetBalanceRequestMessage("hx0000000000000000000000000000000000000000");
            FieldInfo addressFieldInfo = requestMessage.Parameters.GetType().GetField("Address");

            addressFieldInfo.SetValue(requestMessage.Parameters, "hxz000000000000000000000000000000000000000");  // 'hx0000000000000000000000000000000000000000' is correct

            Assert.ThrowsAsync(typeof(RPCInvalidParamsException), async() => await getBalance.Invoke(requestMessage));
        }
コード例 #10
0
ファイル: Anticaptcha.cs プロジェクト: Shifu462/SendToList
        /// <summary>
        /// Get anticaptcha balance.
        /// </summary>
        /// <returns>Returns anticaptcha balance.</returns>
        public float GetBalance()
        {
            var req = new GetBalance {
                ClientKey = AnticaptchaKey
            };

            var reqJson  = JsonConvert.SerializeObject(req);
            var response = (BalanceResult)ExecuteRequest <BalanceResult>(ApiMethodUrl.GetBalance, reqJson, "POST");

            if (response.ErrorId != 0)
            {
                throw new Exception($"{response.ErrorCode} #{response.ErrorId}:\n {response.ErrorDescription}");
            }

            return(response.Balance);
        }
コード例 #11
0
        public void CreditCardPaymentHandler()
        {
            //init
            var dalMock    = new Mock <IPaymentAccessLayer>();
            var getBalance = new GetBalance();

            //act
            new GetBalanceHandler(dalMock.Object).Read(getBalance);

            //assert
            dalMock.Verify(layer =>
                           layer.GetCashBalance(),
                           Times.Once);

            dalMock.Verify(layer =>
                           layer.GetCreditBalance(),
                           Times.Once);
        }
コード例 #12
0
        private void AddPSinhCongNoToDKy(List <GetBalance> dkData, DateTime balanceDate, DateTime fromDate)
        {
            List <GetBalance> psNotDk = new List <GetBalance>();
            // TH ngày đầu kỳ nhỏ hơn ngày bắt đầu thì đi lấy tất cả phát sinh trước ngày bắt đầu
            var psDKData = this.ReportDAO.GetSoTongHopNo(balanceDate, fromDate.AddDays(-1));

            // tính lại đầu kỳ ( đầu kỳ = đầu kỳ + phát sinh)
            if (psDKData != null)
            {
                foreach (var psdk in psDKData)
                {
                    GetBalance item = dkData.Find(o =>
                                                  o.AccountID == psdk.AccountID &&
                                                  o.AccountDetailID == psdk.AccountDetailID &&
                                                  o.CustomerID == psdk.CustomerID);

                    if (item != null)
                    {
                        item.DebitBalance  += psdk.PSNo;
                        item.CreditBalance += psdk.PSCo;
                    }
                    else
                    {
                        psNotDk.Add(new GetBalance
                        {
                            AccountID       = psdk.AccountID,
                            AccountDetailID = psdk.AccountDetailID,
                            CustomerID      = psdk.CustomerID,
                            CustomerSName   = psdk.CustomerSName,
                            CustomerName    = psdk.CustomerName,
                            BalanceDate     = fromDate,
                            DebitBalance    = psdk.PSNo,
                            CreditBalance   = psdk.PSCo
                        });
                    }
                }
            }

            // Thêm phát sinh mà không có đầu kỳ vào list đầu kỳ
            if (psNotDk.Count > 0)
            {
                dkData.AddRange(psNotDk);
            }
        }
コード例 #13
0
ファイル: SetBidsController.cs プロジェクト: kosiaris/BoCBid
        public string GetBalanceAvailable(string accountno)
        {
            var balance = GetBalance.Get(accountno);

            return(balance);
        }
コード例 #14
0
ファイル: CheckBalance.cs プロジェクト: mikevromen/qlabs-qpay
 public CheckBalance(GetBalance getBalance, ILoggerFactory loggerFactory)
 {
     _getBalance = getBalance;
     _logger     = loggerFactory.CreateLogger <CheckBalance>();
 }
コード例 #15
0
 public async Task <GetBalanceResponse> Get([FromUri] GetBalance request)
 {
     return(await GameActions.GetBalanceAsync(request));
 }
コード例 #16
0
        public CreateFakeDatabaseContext()
        {
            string databaseName = Guid.NewGuid().ToString();

            _context = TestContextCreater.Create(databaseName);

            _context.Employees.Add(new Employee()
            {
                CardUid = "04346C824D5380",
                Balance = 10,
                Email   = "*****@*****.**"
            });

            _context.Employees.Add(new Employee()
            {
                CardUid = "99999999999999",
                Balance = 0,
                Email   = "*****@*****.**"
            });

            var terminals = new Faker <Terminal>()
                            .RuleFor(x => x.TerminalId, x => Guid.NewGuid().ToString())
                            .Generate(10);

            _context.Terminals.Add(new Terminal()
            {
                TerminalId = "04346C824D538012",
                ProductId  = 1
            });

            _context.Terminals.AddRange(terminals);

            var products = new Faker <Product>()
                           .RuleFor(x => x.ProductId, x => x.IndexFaker + 1)
                           .RuleFor(x => x.Productname, x => x.Commerce.ProductName())
                           .RuleFor(x => x.ProductDescription, x => x.Lorem.Sentence())
                           .RuleFor(x => x.ProductPrice, x => Convert.ToDecimal((x.Commerce.Price(0.5m, 2m))))
                           .RuleFor(x => x.Terminal, x => x.PickRandom(terminals))
                           .Generate(10);

            _context.Products.AddRange(products);

            var loggerFactory = new LoggerFactory();

            var getBalance = new GetBalance(_context);

            _checkBalance = new CheckBalance(getBalance, loggerFactory);

            var getProduct = new GetProduct(_context);

            _checkTerminal = new CheckTerminal(getProduct, loggerFactory);

            var writeTransaction = new WriteTransaction(_context, loggerFactory);

            _processPayment = new ProcessPayment(writeTransaction);

            var writeNewcard = new WriteNewCard(_context, loggerFactory);

            _newCardScanned = new NewCardScanned(writeNewcard, getProduct);

            _context.SaveChanges();
        }
コード例 #17
0
ファイル: Wallet.cs プロジェクト: arkoc/IconSDK.Net
        public async Task <BigInteger> GetBalance()
        {
            var getBalance = new GetBalance(ApiUrl);

            return(await getBalance.Invoke(Address));
        }
コード例 #18
0
        public async Task <GetBalanceResponse> Get([FromUri] GetBalance request)
        {
            await ValidateTokenData(request);

            return(await GameActions.GetBalanceAsync(request));
        }