public async Task <ActionResult> Edit(string id, FormCollection collection) { try { var ticker = collection["Ticker"].ToString(); var tickerPrice = Convert.ToDouble(collection["Ticker"]); var time = Convert.ToDateTime(collection["Time"]); var stockPriceHistory = new StockPriceHistory() { Id = id, Ticker = ticker, TickerPrice = tickerPrice, Time = time }; //var stockPriceHistoryName = collection["StockPriceHistoryName"].ToString(); //var stockPriceHistory = new StockPriceHistory() //{ // Id = id, // StockPriceHistoryName = stockPriceHistoryName //}; await StockPriceHistoryLib.UpdateStockPriceHistory(stockPriceHistory); return(RedirectToAction("Index")); } catch (Exception ex) { return(View()); } }
public async Task <ActionResult> Create(FormCollection collection) { try { var rand = new Random(); var id = rand.Next().ToString(); var ticker = collection["Ticker"].ToString(); var tickerPrice = Convert.ToDouble(collection["Ticker"]); var time = Convert.ToDateTime(collection["Time"]); var stockPriceHistory = new StockPriceHistory() { Id = id, Ticker = ticker, TickerPrice = tickerPrice, Time = time }; await StockPriceHistoryLib.InsertStockPriceHistory(stockPriceHistory); return(RedirectToAction("Index")); } catch (Exception ex) { return(View()); } }
// GET: StockPriceHistory/Edit/5 public async Task <ActionResult> Edit(string id) { var stockPriceHistory = await StockPriceHistoryLib.GetStockPriceHistory(id.ToString()); if (stockPriceHistory == null) { var errorMsg = string.Format("StockPriceHistory {0} not found.", id); throw new HttpException(404, errorMsg); } return(View(stockPriceHistory)); }
public async Task <ActionResult> Delete(string id, FormCollection collection) { try { await StockPriceHistoryLib.DeleteStockPriceHistory(id); return(RedirectToAction("Index")); } catch { return(View()); } }
//public async void PostAsync([FromBody]string value) // In case there is a POST request, to API/Stock, we refresh the stock prices public async Task PostAsync() { var stockLib = new StockPriceHistoryLib(); await stockLib.RefreshCurrentStockPrices(); }
// GET: StockPriceHistory public async Task <ActionResult> Index() { var stockPriceHistorys = await StockPriceHistoryLib.GetAllStockPriceHistorys(); return(View(stockPriceHistorys)); }