예제 #1
0
        private async Task <List <ApiTransactionResult> > GetWithdrawals(ApiUserTransactionsRequest request)
        {
            var count       = Math.Min(request.Count ?? 100, 1000);
            var cacheResult = await CacheService.GetOrSetHybridAsync(CacheKey.ApiUserTransactions(request.UserId.ToString(), TransactionType.Withdraw), TimeSpan.FromSeconds(60), async() =>
            {
                using (var context = ExchangeDataContextFactory.CreateReadOnlyContext())
                {
                    return(await context.Withdraw
                           .AsNoTracking()
                           .Where(x => x.UserId == request.UserId)
                           .OrderByDescending(x => x.Id)
                           .Take(1000)
                           .Select(x => new ApiTransactionResult
                    {
                        Amount = x.Amount,
                        Confirmations = x.Confirmations,
                        Currency = x.Currency.Symbol,
                        Fee = 0,
                        Id = x.Id,
                        Status = x.Status.ToString(),
                        Timestamp = x.TimeStamp,
                        TxId = x.Txid,
                        Type = "Withdraw",
                        Address = x.Address
                    }).ToListNoLockAsync().ConfigureAwait(false));
                }
            }).ConfigureAwait(false);

            return(cacheResult);
        }