Exemplo n.º 1
0
        /// <summary>
        /// 创建Node
        /// </summary>
        /// <param name="?"></param>
        /// <returns></returns>
        public async Task <CreateNodeOutput> CreateNode(CreateNodeInput input)
        {
            var nodeInfo = new NodeInfo()
            {
                PublishmentSystemId = input.PublishmentSystemId,
                NodeName            = input.NodeName
            };

            if (!string.IsNullOrEmpty(input.NodeIndex))
            {
                nodeInfo.NodeIndexName = input.NodeIndex;
            }
            if (input.ChannelTemplateId.HasValue)
            {
                nodeInfo.ChannelTemplateId = input.ChannelTemplateId.Value;
            }
            if (input.ContentTemplateId.HasValue)
            {
                nodeInfo.ContentTemplateId = input.ContentTemplateId.Value;
            }
            if (!string.IsNullOrEmpty(input.ContentModelId))
            {
                nodeInfo.ContentModelId = input.ContentModelId;
            }
            if (input.ParentId.HasValue)
            {
                nodeInfo.ParentId = input.ParentId.Value;
            }
            else
            {
                nodeInfo.ParentId = input.PublishmentSystemId;
            }

            //检测重复
            var result = await _nodeManager.CheckDuplicateNodeIndex(nodeInfo.Id, nodeInfo.PublishmentSystemId, nodeInfo.NodeIndexName);

            if (!result.Succeeded)
            {
                result.CheckErrors();
            }

            return(Mapper.DynamicMap <CreateNodeOutput>(await _nodeRepository.InsertAsync(nodeInfo)));
        }
Exemplo n.º 2
0
        public async Task <JsonResult> CreateNode(CreateNodeInput input)
        {
            await _nodeAppService.CreateNodeAsync(input);

            return(Json(true, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 3
0
 public async Task CreateNodeAsync(CreateNodeInput input)
 {
     var node = input.Node.MapTo <Node>();
     await _nodeRepository.InsertAsync(node);
 }