Example #1
0
        /// <summary>
        /// Specifies a new route for this cargo.
        /// </summary>
        /// <param name="routeSpecification">Route specification.</param>
        public void SpecifyNewRoute(RouteSpecification routeSpecification)
        {
            if (routeSpecification == null)
            {
                throw new ArgumentNullException("routeSpecification");
            }

            RouteSpecification = routeSpecification;
            Delivery           = Delivery.UpdateOnRouting(RouteSpecification, Itinerary);
        }
Example #2
0
        /// <summary>
        /// Creates new <see cref="Cargo"/> object with provided tracking id and route specification.
        /// </summary>
        /// <param name="trackingId">Tracking id of this cargo.</param>
        /// <param name="routeSpecification">Route specification.</param>
        public Cargo(TrackingId trackingId, RouteSpecification routeSpecification)
        {
            if (trackingId == null)
            {
                throw new ArgumentNullException("trackingId");
            }

            if (routeSpecification == null)
            {
                throw new ArgumentNullException("routeSpecification");
            }

            TrackingId         = trackingId;
            RouteSpecification = routeSpecification;
            Delivery           = Delivery.DerivedFrom(RouteSpecification, Itinerary, null);
        }
Example #3
0
        /// <summary>
        /// Assigns cargo to a provided route.
        /// </summary>
        /// <param name="itinerary">New itinerary</param>
        public void AssignToRoute(Itinerary itinerary)
        {
            if (itinerary == null)
            {
                throw new ArgumentNullException("itinerary");
            }

            var @event = new CargoHasBeenAssignedToRouteEvent(this, Itinerary);
            Itinerary  = itinerary;
            Delivery   = Delivery.UpdateOnRouting(RouteSpecification, Itinerary);

            m_eventAggegator.Publish<CargoHasBeenAssignedToRouteEvent>(@event);
        }
Example #4
0
        /// <summary>
        /// Updates delivery progress information according to handling history.
        /// </summary>
        /// <param name="lastHandlingEvent">Most recent handling event.</param>
        public void DeriveDeliveryProgress(HandlingEvent lastHandlingEvent)
        {
            Delivery = Delivery.DerivedFrom(RouteSpecification, Itinerary, lastHandlingEvent);

            if (Delivery.IsMisdirected)
            {
                m_eventAggegator.Publish<CargoWasMisdirectedEvent>(
                    new CargoWasMisdirectedEvent(this));
            }
            else if (Delivery.IsUnloadedAtDestination)
            {
                m_eventAggegator.Publish<CargoHasArrivedEvent>(
                    new CargoHasArrivedEvent(this));
            }
        }