Exemplo n.º 1
0
        public IActionResult SearchItemUpdateLogic(SearchConditionNode entity)
        {
            if (entity.Id == 0)
            {
                return(View("Update", ResponseModel.Error("Id不能为空", entity)));
            }
            if (string.IsNullOrEmpty(entity.Text))
            {
                return(View("Update", ResponseModel.Error("显示名称不能为空", entity)));
            }

            //更新操作
            var result = conditionAggregationService.Update(entity);

            if (result.IsSuccess)
            {
                return(View("SearchItemUpdate", ResponseModel.Success(1, "修改成功")));
            }
            return(View("SearchItemUpdate", result.ToResponseModel()));
        }
Exemplo n.º 2
0
        public IActionResult AggregateConditionTreeView(int id)
        {
            List <SearchConditionNode> conditions = conditionAggregationService.GetListBySearchConditionId(id);

            SearchConditionNode condition = conditions?.FirstOrDefault(t => t.ParentId == -1);

            if (condition != null)
            {
                condition.Children = GetTree(conditions, condition.Id);
            }

            //Tree Search
            List <SearchConditionNode> GetTree(List <SearchConditionNode> source, int parentId)
            {
                var childs = source.Where(t => t.ParentId == parentId).ToList();

                if (childs == null)
                {
                    return(new List <SearchConditionNode>());
                }
                else
                {
                    childs.ForEach(t => t.Children = GetTree(source, t.Id));
                }
                return(childs);
            }

            if (condition != null)
            {
                return(JsonResultModel.Success("构造树成功!", new List <SearchConditionNode> {
                    condition
                }));
            }
            else
            {
                return(JsonResultModel.Success("构造树成功!", new List <SearchConditionNode>()));
            }
        }