コード例 #1
0
        public ActionResult Remove(string keyValue)
        {
            var resultModel = new RespResultCountViewModel();

            try
            {
                if (string.IsNullOrEmpty(keyValue))
                {
                    resultModel.code = -1;
                    resultModel.msg  = "删除机构失败,缺少主键";
                    return(Ok(resultModel));
                }
                bool existLower = _organizeService.ExistLower(keyValue);
                if (!existLower)
                {
                    bool result = _organizeService.Delete(keyValue, User.GetCurrentUserId(), User.GetCurrentUserName());

                    if (result)
                    {
                        resultModel.code = 0;
                        resultModel.msg  = "删除机构成功";
                    }
                    else
                    {
                        resultModel.code = -1;
                        resultModel.msg  = "删除机构失败";
                    }
                    return(Ok(resultModel));
                }
                else
                {
                    resultModel.code = -1;
                    resultModel.msg  = "删除机构失败,存在子机构";
                    return(Ok(resultModel));
                }
            }
            catch (Exception ex)
            {
                resultModel.code = -1;
                resultModel.msg  = "操作失败:" + ex.ToString();
                resultModel.data = null;
                return(Ok(resultModel));
            }
        }