Пример #1
0
        public async Task <IActionResult> GetBalances([FromQuery, Required] int take, [FromQuery] string continuation)
        {
            if (take < 1)
            {
                return(BadRequest(ErrorResponse.Create("Invalid parameter").AddModelError("take", "Must be positive non zero integer")));
            }
            if (!string.IsNullOrEmpty(continuation))
            {
                try
                {
                    JsonConvert.DeserializeObject <TableContinuationToken>(Utils.HexToString(continuation));
                }
                catch (JsonReaderException)
                {
                    return(BadRequest(ErrorResponse.Create("Invalid parameter").AddModelError("continuation", "Must be valid continuation token")));
                }
            }

            var padedResult = await _balanceService.GetBalances(take, continuation);

            return(Ok(PaginationResponse.From(padedResult.Continuation, padedResult.Items.Select(p => new WalletBalanceContract
            {
                Address = p.Address,
                Balance = MoneyConversionHelper.SatoshiToContract(p.BalanceSatoshi),
                AssetId = Constants.Assets.BitcoinGold.AssetId,
                Block = p.UpdatedAtBlockHeight
            }).ToList().AsReadOnly())));
        }
Пример #2
0
        public async Task <IActionResult> GetBalances([FromQuery] int take, [FromQuery] string continuation)
        {
            if (take <= 0)
            {
                ModelState.AddModelError(nameof(take), "Must be greater than zero");
            }

            ModelState.IsValidContinuationToken(continuation);


            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState.ToErrorResponce()));
            }

            var padedResult = await _balanceService.GetBalances(take, continuation);

            return(Ok(PaginationResponse.From(padedResult.Continuation, padedResult.Items.Select(p => new WalletBalanceContract
            {
                Address = p.Address,
                Balance = MoneyConversionHelper.SatoshiToContract(p.BalanceSatoshi),
                AssetId = Constants.Assets.LiteCoin.AssetId,
                Block = p.UpdatedAtBlockHeight
            }).ToList().AsReadOnly())));
        }
Пример #3
0
        public async Task <PaginationResponse <WalletBalanceContract> > GetBalances([FromQuery] int take, [FromQuery] string continuation)
        {
            if (take <= 0)
            {
                throw new BusinessException("Take must be greater than zero", ErrorCode.BadInputParameter);
            }
            var padedResult = await _balanceService.GetBalances(take, continuation);

            return(PaginationResponse.From(padedResult.Continuation, padedResult.Items.Select(p => new WalletBalanceContract
            {
                Address = p.Address,
                Balance = MoneyConversionHelper.SatoshiToContract(p.BalanceSatoshi),
                AssetId = Constants.Assets.Vertcoin.AssetId
            }).ToList().AsReadOnly()));
        }