public async Task <IActionResult> Edit(int id, [Bind("ID,Name,GradeId,GradeTitle")] Major major) { if (id != major.ID) { return(NotFound()); } if (ModelState.IsValid) { try { major.GradeTitle = _gradeRepository.GetGradeById(major.GradeId.Value).Name; _majorRepository.UpdateMajor(major); _majorRepository.Save(); } catch (DbUpdateConcurrencyException) { if (!majorExists(major.ID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(major)); }
public IActionResult Edit(UpdateMajor model) { if (ModelState.IsValid) { if (majorRepository.UpdateMajor(model) > 0) { return(RedirectToAction("Index", "Major")); } ModelState.AddModelError("", "System error, please try again later!"); } var staffEdit = new UpdateMajor(); return(View(staffEdit)); }