// Refreshes a single stock price public async static Task RefreshCurrentStockPrices(string ticker) { // Gets the yahoo finance url, gets its html, and parses through it to get the price var financeUrl = string.Format("https://finance.yahoo.com/quote/{0}/?p={1}", ticker, ticker); string html = GetHtml(financeUrl); double price = GetStockPrice(html); // Need to use something in the format of Ticker-Date also put in time DateTime dateTime = DateTime.Now; string idDateString = dateTime.ToString("yyyy-MM-dd-HH:mm:ss"); var id = ticker + "-" + idDateString; //var random = new Random(); //var id = random.Next().ToString(); var newStock = new StockPriceHistory() { Id = id, Ticker = ticker, TickerPrice = price, Time = dateTime }; // Asynchronously inserts the data await StockPriceHistoryDataAccess.InsertData(newStock); }
public static async Task <StockPriceHistory> GetStockPriceHistory(string id) { var stockPriceHistory = await StockPriceHistoryDataAccess.GetStockPriceHistoryById(id); return(stockPriceHistory); }
public static async Task <List <StockPriceHistory> > GetAllStockPriceHistorys() { var stockPriceHistorys = await StockPriceHistoryDataAccess.GetAllStockPriceHistorys(); return(stockPriceHistorys); }
public async static Task DeleteStockPriceHistory(string id) { await StockPriceHistoryDataAccess.DeleteData(id); }
public async static Task UpdateStockPriceHistory(StockPriceHistory stockPriceHistory) { await StockPriceHistoryDataAccess.UpdateData(stockPriceHistory); }
public async static Task InsertStockPriceHistory(StockPriceHistory stockPriceHistory) { await StockPriceHistoryDataAccess.InsertData(stockPriceHistory); }