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); }
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); }