/// <summary> /// 公司名称不能重复 /// </summary> /// <param name="organizeName">公司名称</param> /// <param name="keyValue">主键</param> /// <returns></returns> public bool ExistFullName(string organizeName, string keyValue) { return(_organizeService.ExistFullName(organizeName, keyValue)); }
/// <summary> /// 公司名称不能重复 /// </summary> /// <param name="organizeName">公司名称</param> /// <param name="keyValue">主键</param> /// <returns></returns> public bool ExistFullName(string fullName, string keyValue) { return(service.ExistFullName(fullName, keyValue)); }
public ActionResult Create(OrganizeDto model) { var resultModel = new RespResultCountViewModel(); try { #region 验证 if (string.IsNullOrEmpty(model.OrgName)) { resultModel.code = -1; resultModel.msg = "机构名称不允许为空!"; return(Ok(resultModel)); } if (string.IsNullOrEmpty(model.OrgCode)) { resultModel.code = -1; resultModel.msg = "机构代码不允许为空!"; return(Ok(resultModel)); } if (_organizeService.ExistFullName(model.OrgName, model.OrganizeId)) { resultModel.code = -1; resultModel.msg = "已存在相同机构名称!"; return(Ok(resultModel)); } if (_organizeService.ExistEnCode(model.OrgCode, model.OrganizeId)) { resultModel.code = -1; resultModel.msg = "已存在相同机构代码!"; return(Ok(resultModel)); } #endregion if (model.ParentId == null) { model.ParentId = "0"; } OrganizeEntity organizeEntity = _mapper.Map <OrganizeEntity>(model); organizeEntity.OrgBrevityCode = CommonHelper.GetPinyinCode(organizeEntity.OrgName); organizeEntity.OrganizeId = ConstDefine.CreateGuid(); organizeEntity.CreateDate = DateTime.Now; organizeEntity.CreateUserId = User.GetCurrentUserId(); organizeEntity.CreateUserName = User.GetCurrentUserName(); organizeEntity.DeleteMark = 1;//删除标记,原来为0 bool result = _organizeService.Insert(organizeEntity); if (result) { resultModel.code = 0; resultModel.msg = "新增成功"; } else { resultModel.code = -1; resultModel.msg = "新增失败"; } return(Ok(resultModel)); } catch (Exception ex) { resultModel.code = -1; resultModel.msg = "操作失败:" + ex.Message; return(Ok(resultModel)); } }