public ActionResult Create(BuyPrice buyprice) { if (ModelState.IsValid) { db.BuyPrices.Add(buyprice); db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.ProductId = new SelectList(db.Products, "ProductId", "Code", buyprice.ProductId); ViewBag.CustomerTypeId = new SelectList(db.CustomerTypes, "CustomerTypeId", "Name", buyprice.CustomerTypeId); ViewBag.ProductUnitId = new SelectList(db.ProductUnits, "ProductUnitId", "Name", buyprice.ProductUnitId); return View(buyprice); }
public ActionResult Edit(BuyPrice buyprice) { if (ModelState.IsValid) { db.Entry(buyprice).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.ProductId = new SelectList(db.Products, "ProductId", "Code", buyprice.ProductId); ViewBag.CustomerTypeId = new SelectList(db.CustomerTypes, "CustomerTypeId", "Name", buyprice.CustomerTypeId); ViewBag.ProductUnitId = new SelectList(db.ProductUnits, "ProductUnitId", "Name", buyprice.ProductUnitId); return View(buyprice); }