Пример #1
0
        public APIResponseEntity <bool> Delete(JObject obj)
        {
            var request  = obj.ToObject <APIRequestEntity <List <long> > >();
            var response = new APIResponseEntity <bool>();

            if (null == request.Body || request.Body.Count == 0)
            {
                response.IsSuccess = false;
                response.Message   = "请指定要删除的字典ID!";
                return(response);
            }

            request.Body = request.Body.Distinct().ToList();

            //只能删除自己商户的节点
            if (base.IsOnlyCurrentMerchant)
            {
                if (request.Body.Exists(id =>
                {
                    var sysDicModel = sysDicBLL.GetModel(id);
                    return(null != sysDicModel && sysDicModel.FK_MerchantID != base.CurrentUserModel.FK_MerchantID);
                }))
                {
                    response.IsSuccess = false;
                    response.Message   = "只能删除属于自己的商户节点!";
                    return(response);
                }
            }

            int successCount = 0;

            request.Body.ForEach(id =>
            {
                var sysDicModel = sysDicBLL.GetModel(id);
                if (null != sysDicModel)
                {
                    sysDicModel.UpdaterID   = base.CurrentUserModel.UserInfoID;
                    sysDicModel.UpdaterName = base.CurrentUserModel.UserName;
                    sysDicModel.UpdateTime  = DateTime.Now;
                    sysDicModel.RecordState = XCLCMS.Data.CommonHelper.EnumType.RecordStateEnum.D.ToString();
                    if (sysDicBLL.Update(sysDicModel))
                    {
                        successCount++;
                    }
                }
            });

            response.IsSuccess = true;
            response.Message   = string.Format("已成功删除【{0}】条记录!", successCount);

            return(response);
        }
Пример #2
0
        /// <summary>
        /// 删除字典
        /// </summary>
        public APIResponseEntity <bool> Delete(APIRequestEntity <List <long> > request)
        {
            var response = new APIResponseEntity <bool>();

            if (null == request.Body || request.Body.Count == 0)
            {
                response.IsSuccess = false;
                response.Message   = "请指定要删除的字典ID!";
                return(response);
            }

            request.Body = request.Body.Distinct().ToList();

            foreach (var k in request.Body)
            {
                //只能删除层级>2的节点
                var sysDicModel = this.vSysDicBLL.GetModel(k);
                if (sysDicModel.NodeLevel <= 2)
                {
                    response.IsSuccess = false;
                    response.Message   = "只能删除层级>2的节点!";
                    return(response);
                }
            }

            int successCount = 0;

            foreach (var id in request.Body)
            {
                var sysDicModel = sysDicBLL.GetModel(id);
                if (null != sysDicModel)
                {
                    sysDicModel.UpdaterID   = this.ContextInfo.UserInfoID;
                    sysDicModel.UpdaterName = this.ContextInfo.UserName;
                    sysDicModel.UpdateTime  = DateTime.Now;
                    sysDicModel.RecordState = XCLCMS.Data.CommonHelper.EnumType.RecordStateEnum.D.ToString();
                    if (sysDicBLL.Update(sysDicModel))
                    {
                        successCount++;
                    }
                }
            }

            response.IsSuccess = true;
            response.Message   = string.Format("已成功删除【{0}】条记录!", successCount);

            return(response);
        }
Пример #3
0
        public async Task <APIResponseEntity <bool> > Delete([FromBody] APIRequestEntity <List <long> > request)
        {
            return(await Task.Run(() =>
            {
                var response = new APIResponseEntity <bool>();

                if (null == request.Body || request.Body.Count == 0)
                {
                    response.IsSuccess = false;
                    response.Message = "请指定要删除的字典ID!";
                    return response;
                }

                request.Body = request.Body.Distinct().ToList();

                //只能删除自己商户的节点
                if (base.IsOnlyCurrentMerchant)
                {
                    if (request.Body.Exists(id =>
                    {
                        var sysDicModel = sysDicBLL.GetModel(id);
                        return null != sysDicModel && sysDicModel.FK_MerchantID != base.CurrentUserModel.FK_MerchantID;
                    }))
                    {
                        response.IsSuccess = false;
                        response.Message = "只能删除属于自己的商户节点!";
                        return response;
                    }
                }

                foreach (var k in request.Body)
                {
                    //只能删除层级>2的节点
                    var sysDicModel = this.vSysDicBLL.GetModel(k);
                    if (sysDicModel.NodeLevel <= 2)
                    {
                        response.IsSuccess = false;
                        response.Message = "只能删除层级>2的节点!";
                        return response;
                    }
                }

                int successCount = 0;

                foreach (var id in request.Body)
                {
                    var sysDicModel = sysDicBLL.GetModel(id);
                    if (null != sysDicModel)
                    {
                        sysDicModel.UpdaterID = base.CurrentUserModel.UserInfoID;
                        sysDicModel.UpdaterName = base.CurrentUserModel.UserName;
                        sysDicModel.UpdateTime = DateTime.Now;
                        sysDicModel.RecordState = XCLCMS.Data.CommonHelper.EnumType.RecordStateEnum.D.ToString();
                        if (sysDicBLL.Update(sysDicModel))
                        {
                            successCount++;
                        }
                    }
                }

                response.IsSuccess = true;
                response.Message = string.Format("已成功删除【{0}】条记录!", successCount);

                return response;
            }));
        }