示例#1
0
        public void DeleteStock(int ID)
        {
            using (var db = new StockDBContext())
            {
                Stock stock = db.Stocks.Where(s => s.ID == ID).FirstOrDefault();
                db.Stocks.Remove(stock);
                db.SaveChanges();

            }
        }
示例#2
0
        public void AddStock(StockPost newStock)
        {
            Stock stock = new Stock();

            using (var db = new StockDBContext())
            {

                stock.FacebookID = newStock.FacebookID;
                stock.Symbol = newStock.Symbol;
                db.Stocks.Add(stock);
                db.SaveChanges();

            }
        }
示例#3
0
        public List<StocksDTO> GetStocks(string FacebookID)
        {
            List<StocksDTO> stocks;

            using (var db = new StockDBContext())
            {
                stocks = db.Stocks.Where(s => s.FacebookID == FacebookID).Select(t => new StocksDTO()
                  {
                      ID = t.ID,
                      FacebookID = t.FacebookID,
                      Symbol = t.Symbol

                  }).Take(5).ToList();
            }
            return stocks;
        }