コード例 #1
0
        public async Task CreateRouteNodeContainerInCC_1()
        {
            var nodeOfInterestId = Guid.NewGuid();
            var registerNodeOfInterestCommand       = new RegisterNodeOfInterest(Guid.NewGuid(), new UserContext("test", Guid.Empty), nodeOfInterestId, TestRouteNetwork.CC_1);
            var registerNodeOfInterestCommandResult = _commandDispatcher.HandleAsync <RegisterNodeOfInterest, Result <RouteNetworkInterest> >(registerNodeOfInterestCommand).Result;

            var placeNodeContainerCommand = new PlaceNodeContainerInRouteNetwork(Guid.NewGuid(), new UserContext("test", Guid.Empty), Guid.NewGuid(), TestSpecifications.Conduit_Closure_Emtelle_Branch_Box, registerNodeOfInterestCommandResult.Value)
            {
                ManufacturerId = TestSpecifications.Manu_Emtelle
            };

            // Act
            var placeNodeContainerResult = await _commandDispatcher.HandleAsync <PlaceNodeContainerInRouteNetwork, Result>(placeNodeContainerCommand);

            var equipmentQueryResult = await _queryDispatcher.HandleAsync <GetEquipmentDetails, Result <GetEquipmentDetailsResult> >(
                new GetEquipmentDetails(new InterestIdList()
            {
                nodeOfInterestId
            })
                );

            // Assert
            placeNodeContainerResult.IsSuccess.Should().BeTrue();
            equipmentQueryResult.IsSuccess.Should().BeTrue();
            equipmentQueryResult.Value.NodeContainers.Count.Should().Be(1);
        }
        public async void TestPlacingMultipleNodeContainerInSameNode_ShouldFail()
        {
            new TestSpecifications(_commandDispatcher, _queryDispatcher).Run();

            // First node container
            var registerNodeOfInterestCommand1       = new RegisterNodeOfInterest(Guid.NewGuid(), TestRouteNetwork.FP_2);
            var registerNodeOfInterestCommandResult1 = _commandDispatcher.HandleAsync <RegisterNodeOfInterest, Result <RouteNetworkInterest> >(registerNodeOfInterestCommand1).Result;

            var placeNodeContainerCommand1 = new PlaceNodeContainerInRouteNetwork(Guid.NewGuid(), TestSpecifications.Conduit_Closure_Emtelle_Branch_Box, registerNodeOfInterestCommandResult1.Value)
            {
                ManufacturerId = TestSpecifications.Manu_Emtelle
            };

            var firstNodeContainerResult = await _commandDispatcher.HandleAsync <PlaceNodeContainerInRouteNetwork, Result>(placeNodeContainerCommand1);

            // Second node container om same node
            var registerNodeOfInterestCommand2       = new RegisterNodeOfInterest(Guid.NewGuid(), TestRouteNetwork.FP_2);
            var registerNodeOfInterestCommandResult2 = _commandDispatcher.HandleAsync <RegisterNodeOfInterest, Result <RouteNetworkInterest> >(registerNodeOfInterestCommand2).Result;

            var placeNodeContainerCommand2 = new PlaceNodeContainerInRouteNetwork(Guid.NewGuid(), TestSpecifications.Conduit_Closure_Emtelle_Branch_Box, registerNodeOfInterestCommandResult2.Value)
            {
                ManufacturerId = TestSpecifications.Manu_Emtelle
            };

            var secondNodeContainerResult = await _commandDispatcher.HandleAsync <PlaceNodeContainerInRouteNetwork, Result>(placeNodeContainerCommand2);


            // Assert
            firstNodeContainerResult.IsSuccess.Should().BeTrue();
            secondNodeContainerResult.IsSuccess.Should().BeFalse();

            ((PlaceNodeContainerInRouteNetworkError)secondNodeContainerResult.Errors.First()).Code.Should().Be(PlaceNodeContainerInRouteNetworkErrorCodes.NODE_CONTAINER_ALREADY_EXISTS_IN_ROUTE_NODE);
        }
コード例 #3
0
        public async void CreateValidNodeOfInterest_ShouldReturnSuccess()
        {
            var interestId  = Guid.NewGuid();
            var routeNodeId = TestRouteNetwork.CC_1;

            // Act
            var registerNodeOfInterestCommand       = new RegisterNodeOfInterest(Guid.NewGuid(), new UserContext("test", Guid.Empty), interestId, routeNodeId);
            var registerNodeOfInterestCommandResult = await _commandDispatcher.HandleAsync <RegisterNodeOfInterest, Result <RouteNetworkInterest> >(registerNodeOfInterestCommand);

            var routeNetworkQuery = new GetRouteNetworkDetails(new RouteNetworkElementIdList()
            {
                TestRouteNetwork.CC_1
            })
            {
                RelatedInterestFilter = RelatedInterestFilterOptions.ReferencesFromRouteElementAndInterestObjects
            };

            Result <GetRouteNetworkDetailsResult> routeNetworkQueryResult = await _queryDispatcher.HandleAsync <GetRouteNetworkDetails, Result <GetRouteNetworkDetailsResult> >(routeNetworkQuery);

            // Assert command result
            registerNodeOfInterestCommandResult.IsSuccess.Should().BeTrue();
            registerNodeOfInterestCommandResult.Value.Kind.Should().Be(RouteNetworkInterestKindEnum.NodeOfInterest);
            registerNodeOfInterestCommandResult.Value.RouteNetworkElementRefs.Count.Should().Be(1);
            registerNodeOfInterestCommandResult.Value.RouteNetworkElementRefs.Should().Contain(TestRouteNetwork.CC_1);

            // Assert query result
            routeNetworkQueryResult.IsSuccess.Should().BeTrue();
            routeNetworkQueryResult.Value.Interests[interestId].RouteNetworkElementRefs.Count.Should().Be(1);
            routeNetworkQueryResult.Value.Interests[interestId].RouteNetworkElementRefs.Should().Contain(TestRouteNetwork.CC_1);
            routeNetworkQueryResult.Value.RouteNetworkElements[routeNodeId].InterestRelations.Should().Contain(i => i.RefId == interestId && i.RelationKind == RouteNetworkInterestRelationKindEnum.InsideNode);
        }
コード例 #4
0
        private Result PlaceNodeContainer(NpgsqlCommand logCmd, NodeContainerForConversion nodeContainer, Guid specId, RelatedEquipmentInfo relatedInfo)
        {
            Guid correlationId = Guid.NewGuid();

            var commandUserContext = new UserContext("conversion", _workTaskId)
            {
                EditingRouteNodeId = nodeContainer.NodeId
            };

            // Check if node container already exists
            if (relatedInfo.NodeContainer != null)
            {
                if (_utilityNetwork.TryGetEquipment <NodeContainer>(relatedInfo.NodeContainer.Id, out var existingNodeContainer))
                {
                    System.Diagnostics.Debug.WriteLine($"Node container alreadu exists in node: {nodeContainer.NodeId}");
                    return(Result.Ok());
                }
            }

            // First register the node of interest where to place the node container
            var nodeOfInterestId = Guid.NewGuid();

            var registerNodeOfInterestCommand = new RegisterNodeOfInterest(correlationId, commandUserContext, nodeOfInterestId, nodeContainer.NodeId);

            var registerNodeOfInterestCommandResult = _commandDispatcher.HandleAsync <RegisterNodeOfInterest, Result <RouteNetworkInterest> >(registerNodeOfInterestCommand).Result;

            if (registerNodeOfInterestCommandResult.IsFailed)
            {
                LogStatus((NpgsqlCommand)logCmd, _nodeContainerTableName, registerNodeOfInterestCommandResult.Errors.First().Message, nodeContainer.ExternalId);
                return(registerNodeOfInterestCommandResult);
            }

            // Now place the node container in the walk
            var placeNodeContainerCommand = new PlaceNodeContainerInRouteNetwork(correlationId, commandUserContext, nodeContainer.NodeContainerId, specId, registerNodeOfInterestCommandResult.Value)
            {
                ManufacturerId = null,
                LifecycleInfo  = new LifecycleInfo(DeploymentStateEnum.InService, null, null)
            };

            var placeNodeContainerResult = _commandDispatcher.HandleAsync <PlaceNodeContainerInRouteNetwork, Result>(placeNodeContainerCommand).Result;

            // Unregister interest if place node container failed
            if (placeNodeContainerResult.IsFailed)
            {
                LogStatus((NpgsqlCommand)logCmd, _nodeContainerTableName, placeNodeContainerResult.Errors.First().Message, nodeContainer.ExternalId);

                var unregisterCommandResult = _commandDispatcher.HandleAsync <UnregisterInterest, Result>(new UnregisterInterest(correlationId, commandUserContext, nodeOfInterestId)).Result;

                if (unregisterCommandResult.IsFailed)
                {
                    return(unregisterCommandResult);
                }
            }

            LogStatus((NpgsqlCommand)logCmd, _nodeContainerTableName, "external_id", nodeContainer.ExternalId, placeNodeContainerResult);

            return(placeNodeContainerResult);
        }
コード例 #5
0
        private Result PlaceNodeContainer(NodeContainerForConversion nodeContainer, Guid specId)
        {
            var routeNodeId     = Guid.NewGuid();
            var nodeContainerId = Guid.NewGuid();

            Guid correlationId = Guid.NewGuid();

            var commandUserContext = new UserContext("conversion", _workTaskId)
            {
                EditingRouteNodeId = routeNodeId
            };

            // First register the node of interest where to place the node container
            var nodeOfInterestId = Guid.NewGuid();

            var registerNodeOfInterestCommand = new RegisterNodeOfInterest(correlationId, commandUserContext, nodeOfInterestId, routeNodeId);

            var registerNodeOfInterestCommandResult = _commandDispatcher.HandleAsync <RegisterNodeOfInterest, Result <RouteNetworkInterest> >(registerNodeOfInterestCommand).Result;

            if (registerNodeOfInterestCommandResult.IsFailed)
            {
                return(registerNodeOfInterestCommandResult);
            }

            // Now place the node container in the walk
            var placeNodeContainerCommand = new PlaceNodeContainerInRouteNetwork(correlationId, commandUserContext, nodeContainerId, specId, registerNodeOfInterestCommandResult.Value)
            {
                ManufacturerId = null,
                LifecycleInfo  = new LifecycleInfo(DeploymentStateEnum.InService, null, null)
            };

            var placeNodeContainerResult = _commandDispatcher.HandleAsync <PlaceNodeContainerInRouteNetwork, Result>(placeNodeContainerCommand).Result;

            // Unregister interest if place node container failed
            if (placeNodeContainerResult.IsFailed)
            {
                var unregisterCommandResult = _commandDispatcher.HandleAsync <UnregisterInterest, Result>(new UnregisterInterest(correlationId, commandUserContext, nodeOfInterestId)).Result;

                if (unregisterCommandResult.IsFailed)
                {
                    return(unregisterCommandResult);
                }
            }

            return(placeNodeContainerResult);
        }
コード例 #6
0
        private Guid PlaceNodeContainer(Guid routeNodeId)
        {
            var specs = new TestSpecifications(_commandDispatcher, _queryDispatcher).Run();

            var nodeContainerId  = Guid.NewGuid();
            var nodeOfInterestId = Guid.NewGuid();
            var registerNodeOfInterestCommand       = new RegisterNodeOfInterest(nodeOfInterestId, routeNodeId);
            var registerNodeOfInterestCommandResult = _commandDispatcher.HandleAsync <RegisterNodeOfInterest, Result <RouteNetworkInterest> >(registerNodeOfInterestCommand).Result;

            var placeNodeContainerCommand = new PlaceNodeContainerInRouteNetwork(nodeContainerId, TestSpecifications.Conduit_Closure_Emtelle_Branch_Box, registerNodeOfInterestCommandResult.Value)
            {
                ManufacturerId = TestSpecifications.Manu_Emtelle
            };

            var placeNodeContainerResult = _commandDispatcher.HandleAsync <PlaceNodeContainerInRouteNetwork, Result>(placeNodeContainerCommand).Result;

            return(nodeContainerId);
        }
コード例 #7
0
        private Guid PlaceNodeContainer(Guid specificationId, Guid manufacturerId, Guid routeNodeId)
        {
            var nodeOfInterestId = Guid.NewGuid();
            var registerNodeOfInterestCommand       = new RegisterNodeOfInterest(Guid.NewGuid(), new UserContext("test", Guid.Empty), nodeOfInterestId, routeNodeId);
            var registerNodeOfInterestCommandResult = _commandDispatcher.HandleAsync <RegisterNodeOfInterest, Result <RouteNetworkInterest> >(registerNodeOfInterestCommand).Result;

            var placeNodeContainerCommand = new PlaceNodeContainerInRouteNetwork(Guid.NewGuid(), new UserContext("test", Guid.Empty), Guid.NewGuid(), specificationId, registerNodeOfInterestCommandResult.Value)
            {
                ManufacturerId = manufacturerId
            };

            var placeNodeContainerResult = _commandDispatcher.HandleAsync <PlaceNodeContainerInRouteNetwork, Result>(placeNodeContainerCommand).Result;

            if (placeNodeContainerResult.IsFailed)
            {
                throw new ApplicationException(placeNodeContainerResult.Errors.First().Message);
            }

            return(placeNodeContainerCommand.NodeContainerId);
        }
        public async void TestPlaceValidNodeContainer_ShouldSucceed()
        {
            new TestSpecifications(_commandDispatcher, _queryDispatcher).Run();

            var nodeOfInterestId = Guid.NewGuid();
            var registerNodeOfInterestCommand       = new RegisterNodeOfInterest(nodeOfInterestId, TestRouteNetwork.HH_11);
            var registerNodeOfInterestCommandResult = _commandDispatcher.HandleAsync <RegisterNodeOfInterest, Result <RouteNetworkInterest> >(registerNodeOfInterestCommand).Result;

            var placeNodeContainerCommand = new PlaceNodeContainerInRouteNetwork(Guid.NewGuid(), TestSpecifications.Conduit_Closure_Emtelle_Branch_Box, registerNodeOfInterestCommandResult.Value)
            {
                ManufacturerId = TestSpecifications.Manu_Emtelle
            };

            // Act
            var placeNodeContainerResult = await _commandDispatcher.HandleAsync <PlaceNodeContainerInRouteNetwork, Result>(placeNodeContainerCommand);

            var equipmentQueryResult = await _queryDispatcher.HandleAsync <GetEquipmentDetails, Result <GetEquipmentDetailsResult> >(
                new GetEquipmentDetails(new InterestIdList()
            {
                nodeOfInterestId
            })
                );

            // Assert
            placeNodeContainerResult.IsSuccess.Should().BeTrue();
            equipmentQueryResult.IsSuccess.Should().BeTrue();

            equipmentQueryResult.Value.NodeContainers[placeNodeContainerCommand.NodeContainerId].Id.Should().Be(placeNodeContainerCommand.NodeContainerId);
            equipmentQueryResult.Value.NodeContainers[placeNodeContainerCommand.NodeContainerId].SpecificationId.Should().Be(placeNodeContainerCommand.NodeContainerSpecificationId);
            equipmentQueryResult.Value.NodeContainers[placeNodeContainerCommand.NodeContainerId].ManufacturerId.Should().Be(placeNodeContainerCommand.ManufacturerId);
            equipmentQueryResult.Value.NodeContainers[placeNodeContainerCommand.NodeContainerId].InterestId.Should().Be(nodeOfInterestId);
            equipmentQueryResult.Value.NodeContainers[placeNodeContainerCommand.NodeContainerId].VertialContentAlignmemt.Should().Be(NodeContainerVerticalContentAlignmentEnum.Bottom);

            // Check if an event is published to the notification.utility-network topic having an idlist containing the node container we just created
            var utilityNetworkNotifications = _externalEventProducer.GetMessagesByTopic("notification.utility-network").OfType <RouteNetworkElementContainedEquipmentUpdated>();
            var utilityNetworkUpdatedEvent  = utilityNetworkNotifications.First(n => n.IdChangeSets != null && n.IdChangeSets.Any(i => i.IdList.Any(i => i == placeNodeContainerCommand.NodeContainerId)));

            utilityNetworkUpdatedEvent.AffectedRouteNetworkElementIds.Should().Contain(TestRouteNetwork.HH_11);
        }
コード例 #9
0
        public Task <Result <RouteNetworkInterest> > HandleAsync(RegisterNodeOfInterest command)
        {
            var interestProjection = _eventStore.Projections.Get <InterestsProjection>();

            var nodeOfInterest = new RouteNetworkInterest(command.InterestId, RouteNetworkInterestKindEnum.NodeOfInterest, new RouteNetworkElementIdList()
            {
                command.RouteNetworkElementId
            });

            var interestAR = new InterestAR();

            var commandContext = new CommandContext(command.CorrelationId, command.CmdId, command.UserContext);

            var registerInterestResult = interestAR.RegisterNodeOfInterest(commandContext, nodeOfInterest, interestProjection);

            if (registerInterestResult.IsSuccess)
            {
                _eventStore.Aggregates.Store(interestAR);
            }

            return(Task.FromResult(registerInterestResult));
        }
コード例 #10
0
        public async void CreateAndRemoveNodeOfInterest_ShouldReturnSuccess()
        {
            // Route network subset used in this test:
            // (CO_1) <- (S1) -> (HH_1)
            var interestId = Guid.NewGuid();

            var routeNetworkQuery = new GetRouteNetworkDetails(new RouteNetworkElementIdList()
            {
                TestRouteNetwork.CO_1
            })
            {
                RelatedInterestFilter = RelatedInterestFilterOptions.ReferencesFromRouteElementAndInterestObjects
            };

            // Act
            var registerNodeOfInterestCommand       = new RegisterNodeOfInterest(Guid.NewGuid(), new UserContext("test", Guid.Empty), interestId, TestRouteNetwork.CO_1);
            var registerNodeOfInterestCommandResult = await _commandDispatcher.HandleAsync <RegisterNodeOfInterest, Result <RouteNetworkInterest> >(registerNodeOfInterestCommand);

            Result <GetRouteNetworkDetailsResult> routeNetworkQueryResultBefore = await _queryDispatcher.HandleAsync <GetRouteNetworkDetails, Result <GetRouteNetworkDetailsResult> >(routeNetworkQuery);

            var unregisterWalkOfInterestCommand       = new UnregisterInterest(Guid.NewGuid(), new UserContext("test", Guid.Empty), interestId);
            var unregisterWalkOfInterestCommandResult = await _commandDispatcher.HandleAsync <UnregisterInterest, Result>(unregisterWalkOfInterestCommand);

            Result <GetRouteNetworkDetailsResult> routeNetworkQueryResultAfter = await _queryDispatcher.HandleAsync <GetRouteNetworkDetails, Result <GetRouteNetworkDetailsResult> >(routeNetworkQuery);

            // Assert command result
            registerNodeOfInterestCommandResult.IsSuccess.Should().BeTrue();
            unregisterWalkOfInterestCommandResult.IsSuccess.Should().BeTrue();

            // Assert query result
            routeNetworkQueryResultBefore.IsSuccess.Should().BeTrue();
            routeNetworkQueryResultBefore.Value.Interests.ContainsKey(interestId).Should().BeTrue();

            routeNetworkQueryResultAfter.IsSuccess.Should().BeTrue();
            routeNetworkQueryResultAfter.Value.Interests.ContainsKey(interestId).Should().BeFalse();
        }
コード例 #11
0
        public async Task ConnectInnerDuct2In3x10sIn_HH_10()
        {
            var utilityNetwork = _eventStore.Projections.Get <UtilityNetworkProjection>();

            var nodeOfInterestId = Guid.NewGuid();
            var registerNodeOfInterestCommand       = new RegisterNodeOfInterest(Guid.NewGuid(), new UserContext("test", Guid.Empty), nodeOfInterestId, TestRouteNetwork.HH_10);
            var registerNodeOfInterestCommandResult = _commandDispatcher.HandleAsync <RegisterNodeOfInterest, Result <RouteNetworkInterest> >(registerNodeOfInterestCommand).Result;

            var placeNodeContainerCommand = new PlaceNodeContainerInRouteNetwork(Guid.NewGuid(), new UserContext("test", Guid.Empty), Guid.NewGuid(), TestSpecifications.Conduit_Closure_Emtelle_Branch_Box, registerNodeOfInterestCommandResult.Value)
            {
                ManufacturerId = TestSpecifications.Manu_Emtelle
            };

            // Place node container
            var placeNodeContainerResult = await _commandDispatcher.HandleAsync <PlaceNodeContainerInRouteNetwork, Result>(placeNodeContainerCommand);

            // Affix conduit 1
            var testConduitId1 = TestConduits.Conduit_3x10_HH_10_to_HH_11;

            var testConduit1 = _eventStore.Projections.Get <UtilityNetworkProjection>().SpanEquipmentsByEquipmentId[testConduitId1];

            var affixConduitToContainerCommand1 = new AffixSpanEquipmentToNodeContainer(Guid.NewGuid(), new UserContext("test", Guid.Empty),
                                                                                        spanEquipmentOrSegmentId: testConduit1.SpanStructures[0].SpanSegments[0].Id,
                                                                                        nodeContainerId: placeNodeContainerCommand.NodeContainerId,
                                                                                        nodeContainerIngoingSide: NodeContainerSideEnum.North
                                                                                        );

            var affixResult1 = await _commandDispatcher.HandleAsync <AffixSpanEquipmentToNodeContainer, Result>(affixConduitToContainerCommand1);

            affixResult1.IsSuccess.Should().BeTrue();

            // Affix conduit 2
            var testConduitId2 = TestConduits.Conduit_5x10_HH_1_to_HH_10;

            var testConduit2 = _eventStore.Projections.Get <UtilityNetworkProjection>().SpanEquipmentsByEquipmentId[testConduitId2];

            var affixConduitToContainerCommand2 = new AffixSpanEquipmentToNodeContainer(Guid.NewGuid(), new UserContext("test", Guid.Empty),
                                                                                        spanEquipmentOrSegmentId: testConduit2.SpanStructures[0].SpanSegments[0].Id,
                                                                                        nodeContainerId: placeNodeContainerCommand.NodeContainerId,
                                                                                        nodeContainerIngoingSide: NodeContainerSideEnum.South
                                                                                        );

            var affixResult2 = await _commandDispatcher.HandleAsync <AffixSpanEquipmentToNodeContainer, Result>(affixConduitToContainerCommand2);

            affixResult2.IsSuccess.Should().BeTrue();

            // Connect inner conduit 2
            var sutConnectFromSpanEquipment = TestConduits.Conduit_5x10_HH_1_to_HH_10;
            var sutConnectToSpanEquipment   = TestConduits.Conduit_3x10_HH_10_to_HH_11;

            utilityNetwork.TryGetEquipment <SpanEquipment>(sutConnectFromSpanEquipment, out var sutFromSpanEquipment);
            utilityNetwork.TryGetEquipment <SpanEquipment>(sutConnectToSpanEquipment, out var sutToSpanEquipment);

            // Connect inner conduit 2 in 3x10 with inner conduit 2 in the other 3x10 in node HH 10
            var connectCmd = new ConnectSpanSegmentsAtRouteNode(Guid.NewGuid(), new UserContext("test", Guid.Empty),
                                                                routeNodeId: TestRouteNetwork.HH_10,
                                                                spanSegmentsToConnect: new Guid[] {
                sutFromSpanEquipment.SpanStructures[2].SpanSegments[0].Id,
                sutToSpanEquipment.SpanStructures[2].SpanSegments[0].Id
            }
                                                                );

            var connectResult = await _commandDispatcher.HandleAsync <ConnectSpanSegmentsAtRouteNode, Result>(connectCmd);

            connectResult.IsSuccess.Should().BeTrue();
        }
コード例 #12
0
        public NodeContainerMutations(ICommandDispatcher commandDispatcher, IQueryDispatcher queryDispatcher, IEventStore eventStore)
        {
            Description = "Node container mutations";

            FieldAsync <CommandResultType>(
                "placeNodeContainerInRouteNetwork",
                description: "Place a node container (i.e. conduit closure, well, cabinet whatwever) in a route network node",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <IdGraphType> > {
                Name = "routeNodeId"
            },
                    new QueryArgument <NonNullGraphType <IdGraphType> > {
                Name = "nodeContainerId"
            },
                    new QueryArgument <NonNullGraphType <IdGraphType> > {
                Name = "nodeContainerSpecificationId"
            },
                    new QueryArgument <IdGraphType> {
                Name = "manufacturerId"
            }
                    ),
                resolve: async context =>
            {
                var routeNodeId     = context.GetArgument <Guid>("routeNodeId");
                var nodeContainerId = context.GetArgument <Guid>("nodeContainerId");
                var nodeContainerSpecificationId = context.GetArgument <Guid>("nodeContainerSpecificationId");
                var manufacturerId = context.GetArgument <Guid>("manufacturerId");

                var userContext = context.UserContext as GraphQLUserContext;
                var userName    = userContext.Username;

                Guid correlationId = Guid.NewGuid();

                // TODO: Get from work manager
                var workTaskId = Guid.Parse("54800ae5-13a5-4b03-8626-a63b66a25568");

                var commandUserContext = new UserContext(userName, workTaskId)
                {
                    EditingRouteNodeId = routeNodeId
                };

                // First register the walk in the route network where the client want to place the node container
                var nodeOfInterestId = Guid.NewGuid();
                var walk             = new RouteNetworkElementIdList();
                var registerNodeOfInterestCommand = new RegisterNodeOfInterest(correlationId, commandUserContext, nodeOfInterestId, routeNodeId);

                var registerNodeOfInterestCommandResult = await commandDispatcher.HandleAsync <RegisterNodeOfInterest, Result <RouteNetworkInterest> >(registerNodeOfInterestCommand);

                if (registerNodeOfInterestCommandResult.IsFailed)
                {
                    return(new CommandResult(registerNodeOfInterestCommandResult));
                }

                // Now place the conduit in the walk
                var placeNodeContainerCommand = new PlaceNodeContainerInRouteNetwork(correlationId, commandUserContext, nodeContainerId, nodeContainerSpecificationId, registerNodeOfInterestCommandResult.Value)
                {
                    ManufacturerId = manufacturerId,
                    LifecycleInfo  = new LifecycleInfo(DeploymentStateEnum.InService, null, null)
                };

                var placeNodeContainerResult = await commandDispatcher.HandleAsync <PlaceNodeContainerInRouteNetwork, Result>(placeNodeContainerCommand);

                // Unregister interest if place node container failed
                if (placeNodeContainerResult.IsFailed)
                {
                    var unregisterCommandResult = await commandDispatcher.HandleAsync <UnregisterInterest,
                                                                                       Result>(new UnregisterInterest(correlationId, commandUserContext, nodeOfInterestId));

                    if (unregisterCommandResult.IsFailed)
                    {
                        return(new CommandResult(unregisterCommandResult));
                    }
                }

                return(new CommandResult(placeNodeContainerResult));
            }
                );

            FieldAsync <CommandResultType>(
                "reverseVerticalContentAlignment",
                description: "Toggle whether the content in the node container should be drawed from bottom up or top down",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <IdGraphType> > {
                Name = "nodeContainerId"
            }
                    ),
                resolve: async context =>
            {
                var userContext = context.UserContext as GraphQLUserContext;
                var userName    = userContext.Username;

                Guid correlationId = Guid.NewGuid();

                // TODO: Get from work manager
                var workTaskId = Guid.Parse("54800ae5-13a5-4b03-8626-a63b66a25568");

                var commandUserContext = new UserContext(userName, workTaskId);

                var nodeContainerId = context.GetArgument <Guid>("nodeContainerId");

                var reverseAlignmentCmd = new ReverseNodeContainerVerticalContentAlignment(correlationId, commandUserContext, nodeContainerId);

                var reverseAlignmentCmdResult = await commandDispatcher.HandleAsync <ReverseNodeContainerVerticalContentAlignment, Result>(reverseAlignmentCmd);

                return(new CommandResult(reverseAlignmentCmdResult));
            }
                );

            FieldAsync <CommandResultType>(
                "updateProperties",
                description: "Mutation that can be used to change the node container specification and/or manufacturer",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <IdGraphType> > {
                Name = "nodeContainerId"
            },
                    new QueryArgument <IdGraphType> {
                Name = "specificationId"
            },
                    new QueryArgument <IdGraphType> {
                Name = "manufacturerId"
            }
                    ),
                resolve: async context =>
            {
                var nodeContainerId = context.GetArgument <Guid>("nodeContainerId");

                var correlationId = Guid.NewGuid();

                var userContext = context.UserContext as GraphQLUserContext;
                var userName    = userContext.Username;

                // TODO: Get from work manager
                var workTaskId = Guid.Parse("54800ae5-13a5-4b03-8626-a63b66a25568");

                var commandUserContext = new UserContext(userName, workTaskId);

                var updateCmd = new UpdateNodeContainerProperties(correlationId, commandUserContext, nodeContainerId)
                {
                    SpecificationId = context.HasArgument("specificationId") ? context.GetArgument <Guid>("specificationId") : null,
                    ManufacturerId  = context.HasArgument("manufacturerId") ? context.GetArgument <Guid>("manufacturerId") : null,
                };

                var updateResult = await commandDispatcher.HandleAsync <UpdateNodeContainerProperties, Result>(updateCmd);

                return(new CommandResult(updateResult));
            }
                );

            FieldAsync <CommandResultType>(
                "remove",
                description: "Remove node container from the route network node",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <IdGraphType> > {
                Name = "nodeContainerId"
            }
                    ),
                resolve: async context =>
            {
                var nodeContainerId = context.GetArgument <Guid>("nodeContainerId");

                var correlationId = Guid.NewGuid();

                var userContext = context.UserContext as GraphQLUserContext;
                var userName    = userContext.Username;

                // TODO: Get from work manager
                var workTaskId = Guid.Parse("54800ae5-13a5-4b03-8626-a63b66a25568");

                var commandUserContext = new UserContext(userName, workTaskId);

                var removeNodeContainer = new RemoveNodeContainerFromRouteNetwork(
                    correlationId: correlationId,
                    userContext: commandUserContext,
                    nodeContainerId: nodeContainerId
                    );

                var removeResult = await commandDispatcher.HandleAsync <RemoveNodeContainerFromRouteNetwork, Result>(removeNodeContainer);

                return(new CommandResult(removeResult));
            }
                );


            FieldAsync <CommandResultType>(
                "placeRackInNodeContainer",
                description: "Place a rack in the node container",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <IdGraphType> > {
                Name = "nodeContainerId"
            },
                    new QueryArgument <NonNullGraphType <IdGraphType> > {
                Name = "rackId"
            },
                    new QueryArgument <NonNullGraphType <IdGraphType> > {
                Name = "rackSpecificationId"
            },
                    new QueryArgument <NonNullGraphType <StringGraphType> > {
                Name = "rackName"
            },
                    new QueryArgument <NonNullGraphType <IntGraphType> > {
                Name = "rackHeightInUnits"
            }
                    ),
                resolve: async context =>
            {
                var nodeContainerId     = context.GetArgument <Guid>("nodeContainerId");
                var rackId              = context.GetArgument <Guid>("rackId");
                var rackSpecificationId = context.GetArgument <Guid>("rackSpecificationId");
                var rackName            = context.GetArgument <string>("rackName");
                var rackHeightInUnits   = context.GetArgument <int>("rackHeightInUnits");

                var correlationId = Guid.NewGuid();

                var userContext = context.UserContext as GraphQLUserContext;
                var userName    = userContext.Username;

                // TODO: Get from work manager
                var workTaskId = Guid.Parse("54800ae5-13a5-4b03-8626-a63b66a25568");

                var commandUserContext = new UserContext(userName, workTaskId);

                var placeRackInNodeContainer = new PlaceRackInNodeContainer(
                    correlationId: correlationId,
                    userContext: commandUserContext,
                    nodeContainerId: nodeContainerId,
                    rackSpecificationId: rackSpecificationId,
                    rackId: Guid.NewGuid(),
                    rackName: rackName,
                    rackHeightInUnits: rackHeightInUnits
                    );

                var removeResult = await commandDispatcher.HandleAsync <PlaceRackInNodeContainer, Result>(placeRackInNodeContainer);

                return(new CommandResult(removeResult));
            }
                );

            FieldAsync <CommandResultType>(
                "placeTerminalEquipmentInNodeContainer",
                description: "Place a terminal directly in a node container or in a node container rack",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <IdGraphType> > {
                Name = "routeNodeId"
            },
                    new QueryArgument <NonNullGraphType <IdGraphType> > {
                Name = "terminalEquipmentSpecificationId"
            },
                    new QueryArgument <IdGraphType> {
                Name = "manufacturerId"
            },
                    new QueryArgument <NonNullGraphType <IntGraphType> > {
                Name = "numberOfEquipments"
            },
                    new QueryArgument <NonNullGraphType <IntGraphType> > {
                Name = "startSequenceNumber"
            },
                    new QueryArgument <NonNullGraphType <TerminalEquipmentNamingMethodEnumType> > {
                Name = "terminalEquipmentNamingMethod"
            },
                    new QueryArgument <NamingInfoInputType> {
                Name = "namingInfo"
            },
                    new QueryArgument <SubrackPlacementInfoInputType> {
                Name = "subrackPlacementInfo"
            },
                    new QueryArgument <AddressInfoInputType> {
                Name = "addressInfo"
            }
                    ),
                resolve: async context =>
            {
                var routeNodeId = context.GetArgument <Guid>("routeNodeId");
                var terminalEquipmentSpecificationId = context.GetArgument <Guid>("terminalEquipmentSpecificationId");
                var manufacturerId                = context.GetArgument <Guid?>("manufacturerId");
                var numberOfEquipments            = context.GetArgument <int>("numberOfEquipments");
                var startSequenceNumber           = context.GetArgument <int>("startSequenceNumber");
                var terminalEquipmentNamingMethod = context.GetArgument <TerminalEquipmentNamingMethodEnum>("terminalEquipmentNamingMethod");
                var namingInfo           = context.GetArgument <NamingInfo>("namingInfo");
                var subrackPlacementInfo = context.GetArgument <SubrackPlacementInfo>("subrackPlacementInfo");
                var addressInfo          = context.GetArgument <AddressInfo>("addressInfo");

                var getNodeContainerResult = QueryHelper.GetNodeContainerFromRouteNodeId(queryDispatcher, routeNodeId);

                if (getNodeContainerResult.IsFailed)
                {
                    foreach (var error in getNodeContainerResult.Errors)
                    {
                        context.Errors.Add(new ExecutionError(error.Message));
                    }

                    return(null);
                }

                var nodeContainer = getNodeContainerResult.Value;

                var correlationId = Guid.NewGuid();

                var userContext = context.UserContext as GraphQLUserContext;
                var userName    = userContext.Username;

                // TODO: Get from work manager
                var workTaskId = Guid.Parse("54800ae5-13a5-4b03-8626-a63b66a25568");

                var commandUserContext = new UserContext(userName, workTaskId);

                var placeEquipmentInNodeContainer = new PlaceTerminalEquipmentInNodeContainer(
                    correlationId: correlationId,
                    userContext: commandUserContext,
                    nodeContainerId: nodeContainer.Id,
                    terminalEquipmentSpecificationId: terminalEquipmentSpecificationId,
                    terminalEquipmentId: Guid.NewGuid(),
                    numberOfEquipments: numberOfEquipments,
                    startSequenceNumber: startSequenceNumber,
                    namingMethod: terminalEquipmentNamingMethod,
                    namingInfo: namingInfo
                    )
                {
                    AddressInfo          = addressInfo,
                    SubrackPlacementInfo = subrackPlacementInfo,
                    ManufacturerId       = manufacturerId
                };

                var removeResult = await commandDispatcher.HandleAsync <PlaceTerminalEquipmentInNodeContainer, Result>(placeEquipmentInNodeContainer);

                return(new CommandResult(removeResult));
            }
                );
        }