public ActionResult Create(Store store) { if (ModelState.IsValid) { db.Stores.Add(store); db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.ProductId = new SelectList(db.Products, "ProductId", "Name", store.ProductId); ViewBag.ProductUnitId = new SelectList(db.ProductUnits, "ProductUnitId", "Name", store.ProductUnitId); return View(store); }
public ActionResult Edit(Store store) { if (ModelState.IsValid) { db.Entry(store).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.ProductId = new SelectList(db.Products, "ProductId", "Name", store.ProductId); ViewBag.ProductUnitId = new SelectList(db.ProductUnits, "ProductUnitId", "Name", store.ProductUnitId); return View(store); }