示例#1
0
        public async Task <bool> IsExist(Expression <Func <DataDefineLibraryModel, bool> > predicate)
        {
            var ret = await _dlr.Find(predicate).FirstOrDefaultAsync();

            if (ret != null)
            {
                return(true);
            }
            return(false);
        }
示例#2
0
        public async Task <BaseResponse> DeleteCategoryAsync(string Account, int Id)
        {
            var cate = await _cr.FindAsync(Id);

            if (cate == null)
            {
                return(new BaseResponse {
                    Success = false, Message = "输入的分类标示不存在"
                });
            }
            //查找datadefinelibrary和typedatadefine中是否使用
            var dl = await _dl.Find(a => a.Category != null).ToListAsync();

            var dle = dl.Where(a => a.Category.Split(',').Contains(Id.ToString()));

            if (dle.Count() > 0)
            {
                return(new BaseResponse {
                    Success = false, Message = "数据定义库中存在使用该分类标示的数据,不能删除"
                });
            }
            var dt = await _tr.Find(a => a.Category != null).ToListAsync();

            var tle = dt.Where(a => a.Category.Split(',').Contains(Id.ToString()));

            if (tle.Count() > 0)
            {
                return(new BaseResponse {
                    Success = false, Message = "类型数据定义中存在使用该分类标示的数据,不能删除"
                });
            }
            try
            {
                await _cr.RemoveAsync(cate);

                _log.LogInformation($"{Account}删除标示为{Id}的分类数据成功");
                return(new BaseResponse {
                    Success = true, Message = "删除分类数据成功"
                });
            }
            catch (Exception ex)
            {
                _log.LogError($"{Account}删除标示为{Id}的分类数据失败,失败原因:{ex.Message}->{ex.StackTrace}->{ex.InnerException}");
                return(new BaseResponse {
                    Success = false, Message = "删除数据失败,请联系管理员"
                });
            }
        }