Exemple #1
0
        public Task <CreateComponentsAndRelationsResponseDto> CreateComponentsAndRelations(string versionId, CreateComponentsAndRelationsDto createComponentsAndRelationsDto)
        {
            try
            {
                var nodes         = new List <CreateComponentsAndRelationsRequestDtoNode>();
                var relationships = new List <CreateComponentsAndRelationsRequestDtoRelationship>();

                foreach (var node in createComponentsAndRelationsDto.nodes)
                {
                    nodes.Add(new CreateComponentsAndRelationsRequestDtoNode
                    {
                        name           = node.name,
                        description    = node.description,
                        displayName    = node.displayName,
                        icon           = node.icon,
                        orderIndex     = node.orderIndex,
                        statusMessages = new object[0],
                        tags           = new string[]
                        {
                            DesignConst.Create_Component_Tag_Consumer_Visible
                        },
                        typeId = node.typeId,
                        x      = node.x,
                        y      = node.y
                    });
                }

                foreach (var relationship in createComponentsAndRelationsDto.relationships)
                {
                    relationships.Add(new CreateComponentsAndRelationsRequestDtoRelationship
                    {
                        name               = relationship.name,
                        displayName        = relationship.displayName,
                        relationshipTypeId = relationship.relationshipTypeId,
                        source             = new CreateComponentsAndRelationsRequestDtoSource
                        {
                            name = relationship.sourceName
                        },
                        target = new CreateComponentsAndRelationsRequestDtoTarget
                        {
                            name = relationship.targetName
                        }
                    });
                }

                var data = new CreateComponentsAndRelationsRequestDto
                {
                    groups        = new object[0],
                    nodes         = nodes.ToArray(),
                    relationships = relationships.ToArray()
                };

                return(SendSmaxHcm <CreateComponentsAndRelationsResponseDto>(HttpMethod.Put, string.Format(SmaxHcmEndpointConst.CreateComponentsAndRelations, SmaxHcmOptions.TenantId, versionId), data, false, true));
            }
            catch (Exception ex)
            {
                throw new SmaxHcmGenericException($"Error on creting components and relations - {ex.Message}");
            }
        }
 public async Task <IActionResult> CreateComponentsAndRelations(string versionId, CreateComponentsAndRelationsDto createComponentsAndRelationsDto)
 {
     Devon4NetLogger.Debug("Executing CreateComponentsAndRelations from controller SmaxHcm");
     return(Ok(await SmaxHcmHandler.CreateComponentsAndRelations(versionId, createComponentsAndRelationsDto)));
 }