Exemplo n.º 1
0
        /// <summary>
        /// Refresh or add a stock symbol.
        /// </summary>
        /// <param name="symbol">
        /// The symbol.
        /// </param>
        /// <returns>
        /// The <see cref="Task"/>.
        /// </returns>
        public async Task<StockQuote> RefreshOrAdd(string symbol)
        {
            var quote = new StockQuote();

            if (string.IsNullOrEmpty(symbol))
            {
                return quote;
            }

            try
            {
                quote = await this.stockQuoteService.GetStockQuoteAsync(symbol);
                var existingQuote = this.StockQuotes.Data.Cast<StockQuote>().FirstOrDefault(a => a.Symbol == symbol);

                if (existingQuote == null)
                {
                    this.StockQuotes.Add(quote);
                }
                else
                {
                    this.StockQuotes.Replace(existingQuote, quote);
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine (ex.Message);
            }
            return quote;
        }
Exemplo n.º 2
0
 /// <summary>
 /// Bind the specified stock.
 /// </summary>
 /// <param name="stock">Stock.</param>
 public void Bind(StockQuote stock)
 {
     this.stockQuote = stock;
     this.textName.Text = stock.Name;
     this.textLast.Text = stock.Last;
 }