private void OnConduitClosurePlaced(ConduitClosureInfo conduitClosureInfo, ConduitClosurePlaced @event) { conduitClosureInfo.Id = @event.ConduitClosureId; conduitClosureInfo.PointOfInterestId = @event.PointOfInterestId; // Add four sides conduitClosureInfo.Sides = new List <ConduitClosureSideInfo>(); for (int i = 0; i < 4; i++) { conduitClosureInfo.Sides.Add(new ConduitClosureSideInfo() { Position = (ConduitClosureInfoSide)i + 1, Ports = new List <ConduitClosurePortInfo>() }); } ; conduitClosureRepository.UpdateConduitClosureInfo(conduitClosureInfo); }
public ConduitClosure(Guid conduitClosureId, Guid pointOfInterestId, IRouteNetworkState routeNetworkQueryService, IConduitNetworkQueryService conduitNetworkQueryService, IConduitClosureRepository conduitClosureRepository) : this() { // Id check if (conduitClosureId == null || conduitClosureId == Guid.Empty) { throw new ArgumentException("ConduitClosureId cannot be null or empty"); } // Point of interest id check if (pointOfInterestId == null || pointOfInterestId == Guid.Empty) { throw new ArgumentException("PointOfInterestId cannot be null or empty"); } // Check that point of interest (node) exists if (!routeNetworkQueryService.CheckIfRouteNodeIdExists(pointOfInterestId)) { throw new ArgumentException("PointOfInterestId: " + pointOfInterestId + " not found in the route network."); } // Check that conduit closure do not already exists if (conduitClosureRepository.CheckIfConduitClosureAlreadyExists(conduitClosureId)) { throw new ArgumentException("A conduit closure with id: " + conduitClosureId + " already exists."); } // Check that a conduit closure is not already added to point of interest. This is not allowed, each conduit closure must be placed in its own node. if (conduitClosureRepository.CheckIfRouteNodeContainsConduitClosure(pointOfInterestId)) { throw new ArgumentException("A conduit closure: " + conduitClosureRepository.GetConduitClosureInfoByRouteNodeId(pointOfInterestId).Id + " is already placed in the specified point of interest (route node): " + pointOfInterestId + " Only one conduit closure is allowed per point of interest (route node)."); } var conduitClosurePlaced = new ConduitClosurePlaced() { ConduitClosureId = conduitClosureId, PointOfInterestId = pointOfInterestId }; RaiseEvent(conduitClosurePlaced); }
private void Apply(ConduitClosurePlaced @event) { Id = @event.ConduitClosureId; _pointOfInterestId = @event.PointOfInterestId; }