public async Task <ActionResult> EditMajor(MajorEditViewModel model) { if (ModelState.IsValid) { var major = await InstitutionManager.FindMajorByIdAsync(model.Id); if (major == null) { ModelState.AddModelError("", "未找到此项major"); return(View(model)); } var depart = await InstitutionManager.FindDepartmentByIdAsync(model.DepartmentId); if (depart == null) { ModelState.AddModelError("", "未找到此项depart"); return(View(model)); } major.Name = model.MajorName; major.Department = depart; await InstitutionManager.UpdateMajorAsync(major); return(RedirectToAction("AllMajor")); } return(View(model)); }