public ActionResult Edit(STAKEHOLDER stakeholder) { if (ModelState.IsValid) { stakeholderRepository.InsertOrUpdate(stakeholder); stakeholderRepository.Save(); return RedirectToAction("Index"); } else { return View(); } }
public void InsertOrUpdate(STAKEHOLDER stakeholder) { if (stakeholder.ID == default(int)) { // New entity context.STAKEHOLDER.Add(stakeholder); } else { // Existing entity context.Entry(stakeholder).State = System.Data.Entity.EntityState.Modified; } }