示例#1
0
        public ActionResult Create(Stock stock)
        {
            if (ModelState.IsValid)
            {
                db.Stocks.Add(stock);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            ViewBag.StockTypeId = new SelectList(db.StockTypes, "Id", "Type", stock.StockTypeId);
            return View(stock);
        }
示例#2
0
 public ActionResult Edit(Stock stock)
 {
     if (ModelState.IsValid)
     {
         db.Entry(stock).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     ViewBag.StockTypeId = new SelectList(db.StockTypes, "Id", "Type", stock.StockTypeId);
     return View(stock);
 }