Beispiel #1
0
        public Object GetContributionStat()
        {
            string userId       = CurrentUserId;
            var    contribution = new ContributionCore(CurrentUserId, dc, Database.Configuration);
            var    addresses    = dc.Table <TokenWalletAddress>().Where(x => x.UserId == userId).ToList();

            var pairs = new MarketCore(dc, Database.Configuration).GetUsdPrices();

            var btcAmount = 0; // addresses.FirstOrDefault(x => x.Currency == "BTC")?.Amount;
            var ethAmount = 0; // addresses.FirstOrDefault(x => x.Currency == "ETH")?.Amount;

            var btcAmountUsd = btcAmount * pairs.First(x => x.Base == "BTC" && x.Currency == "USD").Amount;
            var ethAmountUsd = ethAmount * pairs.First(x => x.Base == "ETH" && x.Currency == "USD").Amount;

            return(new
            {
                Items = new List <Object>
                {
                    new
                    {
                        Currency = "BTC",
                        Amount = btcAmount,
                        AmountUsd = btcAmountUsd
                    },

                    new
                    {
                        Currency = "ETH",
                        Amount = ethAmount,
                        AmountUsd = ethAmountUsd
                    }
                },

                Total = btcAmountUsd + ethAmountUsd
            });
        }
Beispiel #2
0
        public Object GetPayableAddresses()
        {
            string userId       = CurrentUserId;
            var    contribution = new ContributionCore(CurrentUserId, dc, Database.Configuration);
            var    addresses    = dc.Table <TokenWalletAddress>().Where(x => x.UserId == userId).ToList();

            var pairs = new MarketCore(dc, Database.Configuration).GetUsdPrices();

            return(new List <Object>
            {
                new
                {
                    Currency = "BTC",
                    addresses.FirstOrDefault(x => x.Currency == "BTC")?.Address,
                    Rate = pairs.First(x => x.Base == "BTC").Amount
                },
                new
                {
                    Currency = "ETH",
                    addresses.FirstOrDefault(x => x.Currency == "ETH")?.Address,
                    Rate = pairs.First(x => x.Base == "ETH").Amount
                }
            });
        }