public async Task <ActionResult> CreateGrade(GradeCreateViewModel model) { if (ModelState.IsValid) { if (model.GradeNumber == 0) { ModelState.AddModelError("", "GradeNumber不能为0"); } else { var grade = await InstitutionManager.FindGradeByGradeNumberAsync(model.GradeNumber); if (grade == null) { await InstitutionManager.AddGradeAsync(model.GradeNumber); return(RedirectToAction("AllGrade")); } else { ModelState.AddModelError("", "已有相同名称"); } } } return(View(model)); }