public void InsertOrUpdate(VendorPlus vendorPlus) { if (vendorPlus.BusinessEntityID == default(int)) { // New entity context.VendorsPlus.Add(vendorPlus); } else { // Existing entity context.Entry(vendorPlus).State = EntityState.Modified; } }
public ActionResult Create(VendorPlus vvendorwithaddress) { if (ModelState.IsValid) { vendorContext.InsertOrUpdate(vvendorwithaddress); vendorContext.Save(); return RedirectToAction("Index"); } return View(vvendorwithaddress); }
public ActionResult Edit(VendorPlus vvendorwithaddress) { if (ModelState.IsValid) { //vendorContext.Find(vvendorwithaddress.BusinessEntityID)).State = EntityState.Modified; vendorContext.Save(); return RedirectToAction("Index"); } return View(vvendorwithaddress); }