Exemple #1
0
        public IActionResult Add([FromBody] TaskGraphAddModel taskGraph)
        {
            var userList = new List <Guid>();

            userList.Add(taskGraph.UserId);
            var tgModel = new TaskGraph
            {
                Id          = Guid.NewGuid(),
                Description = taskGraph.Description,
                Name        = taskGraph.Name,
                RootId      = null,
                TaskSetId   = null,
                ActiveUsers = userList,
                WorkspaceId = taskGraph.WorkspaceId
            };

            return(Ok(ServiceFactory.TaskGraphService.Add(tgModel)));
        }
Exemple #2
0
        public IActionResult Add([FromBody] TaskGraphAddModel taskGraph)
        {
            var taskGraphData = new DataTransfer.Events.TaskGraph
            {
                Description = taskGraph.Description,
                Name        = taskGraph.Name,
                Root        = null,
                Id          = Guid.NewGuid(),
                WorkspaceId = taskGraph.WorkspaceId,
                UserId      = taskGraph.UserId
            };

            string topicEndpoint = "https://accelerant-task-topic.francecentral-1.eventgrid.azure.net/api/events";

            string topicKey = "xBCWj/db0/+GiJnkgAsdLClZxCtPZStDbwKFJxQ40R0=";

            string           topicHostname    = new Uri(topicEndpoint).Host;
            TopicCredentials topicCredentials = new TopicCredentials(topicKey);
            EventGridClient  client           = new EventGridClient(topicCredentials);

            var eventsList = new List <EventGridEvent>();

            eventsList.Add(new EventGridEvent()
            {
                Id          = Guid.NewGuid().ToString(),
                EventType   = "Accelerant.TaskGraphs.AddItem",
                Data        = taskGraphData,
                EventTime   = DateTime.Now,
                Subject     = "accelerant-task-topic",
                DataVersion = "2.0"
            });

            client.PublishEventsAsync(topicHostname, eventsList).GetAwaiter().GetResult();

            return(Ok(taskGraphData));
        }