Пример #1
0
        //api/stocks/postbuy
        public HttpResponseMessage PostBuy(StockInfo stockInfo)
        {
            StockInfo st = db.StockInfos.Where(x => x.StockName == stockInfo.StockName).FirstOrDefault();

            db.StockInfos.Where(x => x.StockName == stockInfo.StockName).FirstOrDefault().TotalBought = st.TotalBought + stockInfo.TotalBought;
            db.StockInfos.Where(x => x.StockName == stockInfo.StockName).FirstOrDefault().Thoughts    = stockInfo.Thoughts;
            db.SaveChanges();

            return(Request.CreateResponse(HttpStatusCode.OK));
        }
Пример #2
0
        public ActionResult Create([Bind(Include = "SymbolID")] Stock stock)
        {
            if (ModelState.IsValid)
            {
                db.Stocks.Add(stock);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(stock));
        }