public ActionResult Edit(ProfessorModel data) { bool result = repository.Edit(data); if(result == false) return View(data); return RedirectToAction("Index", "Home"); }
public bool Add(ProfessorModel data) { using (var DB = new MainContext()) { DB.Professors.Add(data); DB.SaveChanges(); return true; } return false; }
public bool Edit(ProfessorModel data) { using (var DB = new MainContext()) { DB.Professors.Attach(data); DB.Entry(data).State = System.Data.Entity.EntityState.Modified; DB.SaveChanges(); return true; } return false; }