Example #1
0
    private void showStoredData(Data_AppUserWallet wal)
    {
        PriceAndText price = wal.CalucateCost();

        TitleId.Text  = wal.Title;
        userName.Text = sd.LoggedOnUserName;
        InfoText.Text = wal.DisplayLinesAsHTML();
        CalcInfo.Text = price.Explained;

        commitTextDiv.Visible = true;
        CalcInfoDiv.Visible   = true;

        alterStep1DivVisibility(false, null, 0, 0, 0, 0);
        CalcInfoDiv.Visible        = true;
        CommitDiv.Visible          = false;
        PaymentInstruction.Visible = true;
        paypalAmount.Text          = String.Format("{0:0.00} USD", price.FinalPrice);
        paypalLink.HRef            = String.Format("https://PayPal.me/NiceAPI/{0:0.00}usd", price.FinalPrice);

        try
        {
            BitcoinPrice.BitcoinPriceInfos currentPrice = BitcoinPrice.PriceFromGecko();
            btcAmount.Text = String.Format("{0:0.00000} BTC", price.FinalPrice / currentPrice.btc.PriceInUSD);
            bchAmount.Text = String.Format("{0:0.00000} BCH", price.FinalPrice / currentPrice.bch.PriceInUSD);
        }
        catch
        { }
    }
        public async Task <ITweet> SendTweet(BitcoinPrice price)
        {
            var changed = price.LastDayChange < 0 ? "decreased" : "increased";
            var tweet   = $"The current price of bitcoin is {price.Current.ToString("C")}. It has {changed} by {price.LastDayChange.ToString("F")}% in the last 24 hours #bitcoin #btc #cryptocurrency";

            return(await _client.Tweets.PublishTweetAsync(tweet));
        }
Example #3
0
 static void BitcoinPrices()
 {
     string content = string.Empty;
     string bitUrl = "https://api.coindesk.com/v1/bpi/currentprice.json";
     using (var wc = new WebClient())
     {
         content = wc.DownloadString(bitUrl);
     }
     BitcoinPrice bitFact = JsonSerializer.Deserialize<BitcoinPrice>(content);
     Console.WriteLine();
     Console.ForegroundColor = ConsoleColor.Yellow;
     Console.WriteLine("As Of - " + bitFact.Time.Updated);
     Console.WriteLine("USD - $ " + bitFact.Bpi.USD.Rate);
     Console.WriteLine();
 }
Example #4
0
        static void BitcoinPrices()
        {
            string     content = string.Empty;
            string     bitUrl  = "https://api.coindesk.com/v1/bpi/currentprice.json";
            WebRequest bitReq  = WebRequest.Create(bitUrl);

            using (WebResponse wr = bitReq.GetResponse())
                using (Stream receiveStream = wr.GetResponseStream())
                    using (StreamReader sReader = new StreamReader(receiveStream, Encoding.UTF8))
                        content = sReader.ReadToEnd();
            BitcoinPrice bitFact = JsonSerializer.Deserialize <BitcoinPrice>(content);

            Console.WriteLine("");
            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.WriteLine("As Of - " + bitFact.time.updated);
            Console.WriteLine("USD - $ " + bitFact.bpi.USD.rate);
            Console.WriteLine("");
        }
Example #5
0
        protected override void OnDownloadComplete(
            string content)
        {
            Debug.Assert(string.IsNullOrWhiteSpace(content) == false);

            try
            {
                BitcoinPrice price = JsonConvert.DeserializeObject <BitcoinPrice>(content);
                Debug.Assert(price != null);

                dollarPerBitcoin = double.Parse(price.Bpi.USD.Rate, NumberStyles.Any, CultureInfo.InvariantCulture);
                Miner.instance.OnStatsChange();
            }
            catch (Exception e)
            {
                Log.ParsingError(nameof(APIBitcoinPrice), nameof(OnDownloadComplete), e);
            }
        }
        private BitcoinPrice getBitCoinPrice()
        {
            var mockBitCoinTime = new BitcoinTime();

            mockBitCoinTime.Updated = "Just now";

            var mockbitCoinBpi = new BitcoinBpi()
            {
                USD = new Currency()
                {
                    Rate = "1000"
                }
            };

            var mockBitCoinPrice = new BitcoinPrice
            {
                Bpi  = mockbitCoinBpi,
                Time = mockBitCoinTime
            };

            return(mockBitCoinPrice);
        }
        public void Run()
        {
            string       content = string.Empty;
            string       bitUrl  = "https://api.coindesk.com/v1/bpi/currentprice.json";
            BitcoinPrice bitFact = new BitcoinPrice();

            try {
                using (var wc = GetWebClient())
                {
                    content = wc.DownloadString(bitUrl);
                }
                bitFact = JsonSerializer.Deserialize <BitcoinPrice>(content);
            }
            catch {
                Console.WriteLine("Got no result or couldn't convert to bitcoin pricing");
            }

            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.WriteLine(bitFact?.Disclaimer);
            Console.WriteLine("As Of - " + bitFact?.Time?.Updated);
            Console.WriteLine("USD - $ " + bitFact?.Bpi?.USD?.Rate);
            Console.WriteLine();
        }