예제 #1
0
        public async Task <IActionResult> Install([FromBody] AgentMarketplaceDto agentDefaultDto, CancellationToken cancellationToken)
        {
            var agentExist = await this.agentService.AnyAsync(t => t.Name == agentDefaultDto.Name, cancellationToken);

            if (agentExist)
            {
                return(BadRequest(ERROR_AGENT_EXIT));
            }

            var agent = this.mapper.Map <AgentMarketplaceDto, Agent>(agentDefaultDto);

            agent.Script = await this.agentService.GetScriptAsync(agentDefaultDto.ScriptUrl, cancellationToken);

            var agentInstalled = await this.agentService.AddAgentAsync(agent, "Agent Installed", cancellationToken);

            return(Ok(this.mapper.Map <Agent, AgentDto>(agentInstalled)));
        }
        public ICollection <Category> Resolve(AgentMarketplaceDto source, Agent destination, ICollection <Category> member, ResolutionContext context)
        {
            var agentCategories = new List <Category>();

            var category = this.categoryService.GetByCriteriaAsync(c => c.Name == source.Category).Result;

            if (category != null)
            {
                agentCategories.Add(category);
            }
            else
            {
                agentCategories.Add(new Category
                {
                    Name = source.Category
                });
            }

            return(agentCategories);
        }