public ActionResult Create(ArticleCateViewModel model) { ViewBag.Data_PID = GetSelectList(); ServiceResult result = new ServiceResult(); TempData["Service_Result"] = result; if (ModelState.IsValid) { try { ArticleCate entity = new ArticleCate(); entity.CateName = model.CateName; entity.PID = model.PID == 0 ? null : model.PID; entity.Level = model.Level; entity.OrderIndex = model.OrderIndex; entity.IsSingle = model.IsSingle; entity.Code = model.Code; articleCateService.Create(entity); result.Message = "添加文章分类成功!"; LogHelper.WriteLog("添加文章分类成功"); return(RedirectToAction("index")); } catch (DbEntityValidationException ex) { result.Message = Utilities.GetInnerMostException(ex); result.AddServiceError(result.Message); LogHelper.WriteLog("添加文章分类错误", ex); return(View(model)); } } else { result.Message = "请检查表单是否填写完整!"; result.AddServiceError("请检查表单是否填写完整!"); return(View(model)); } }