public ActionResult AddUnit(BuildUnitSearchModel model) { JsonModel jm = new JsonModel(); IBuildUnitBLL unitBll = BLLFactory <IBuildUnitBLL> .GetBLL("BuildUnitBLL"); if (unitBll.Exist(m => m.UnitName == model.UnitName && m.Id != model.UnitId && m.BuildId == model.BuildId)) { jm.Msg = "该单元名称已经存在"; } //如果表单模型验证成功 else if (ModelState.IsValid) { T_BuildUnit newUnit = new T_BuildUnit() { UnitName = model.UnitName, BuildId = model.BuildId }; // 保存到数据库 unitBll.Save(newUnit); //日志记录 jm.Content = PropertyUtils.ModelToJsonString(model); } else { // 保存异常日志 jm.Msg = ConstantParam.JSON_RESULT_MODEL_CHECK_ERROR; } return(Json(jm, JsonRequestBehavior.AllowGet)); }
/// <summary> /// 远程验证指定单元名称是否存在 /// </summary> /// <param name="unitName">单元名称</param> /// <param name="id">单元id,新增时恒为0,修改单元名称时不为0</param> public ContentResult RemoteCheckExist(BuildUnitSearchModel model) { IBuildUnitBLL unitBll = BLLFactory <IBuildUnitBLL> .GetBLL("BuildUnitBLL"); // 楼座名称已存在 if (unitBll.Exist(m => m.UnitName == model.UnitName && m.Id != model.UnitId && m.BuildId == model.BuildId)) { // 校验不通过 return(Content("false")); } else { return(Content("true")); } }