public async Task <ActionResult> CreateDepartment(Department department) { if (ModelState.IsValid) { if (!string.IsNullOrEmpty(department.Name)) { var depart = await InstitutionManager.FindDepartmentByNameAsync(department.Name); if (depart == null) { await InstitutionManager.AddDepartmentAsync(department.Name); return(RedirectToAction("AllDepartment")); } else { ModelState.AddModelError("", "已有相同名称"); } } else { ModelState.AddModelError("", "不能为空"); } } return(View(department)); }