コード例 #1
0
        public async Task <JsonResult> GetAll([FromBody] QueryInfo searchRequestInfo)
        {
            var result = await _cryptoCurrencyService.GetAll(searchRequestInfo);

            return(new JsonResult(new
            {
                data = new { records = result.DataSource, count = result.Count },
                resultCode = 0
            }));
        }
コード例 #2
0
        private async void GetInfo(object state)
        {
            List <CryptoCurrency> cryptoCurrencies = (List <CryptoCurrency>) await _cryptoCurrencyService.GetAll();

            List <CryptoWidget> widgets = new();

            foreach (var crypto in cryptoCurrencies)
            {
                CryptoInfo info = await _cryptoInfoService.GetCryptoInfo((CryptoType)crypto.Id - 1);

                CryptoWidget widget = new(info.Ticker.Base);
                widget.Name   = info.Ticker.Base;
                widget.Price  = info.Ticker.Price;
                widget.Change = Math.Round((info.Ticker.Price - crypto.CurrentPrice), 2);
                if (widget.Change > 0)
                {
                    widget.Color = "Green";
                }
                else if (widget.Change < 0)
                {
                    widget.Color = "Red";
                }
                else
                {
                    widget.Color = "#faff78";
                }

                widgets.Add(widget);
                crypto.CurrentPrice = info.Ticker.Price;
                await _cryptoCurrencyService.Update(crypto.Id, crypto);
            }

            Dispatcher.CurrentDispatcher.Invoke(() =>
            {
                for (int i = 0; i < 10; i++)
                {
                    var widget    = Labels[i];
                    var update    = widgets[i];
                    widget.Name   = update.Name;
                    widget.Price  = update.Price;
                    widget.Change = update.Change;
                    widget.Color  = update.Color;
                }
            });
        }