/// <summary> /// Merges the current <see cref="Freight.Itinerary"/> with the provided <see cref="Freight.Itinerary"/> /// </summary> /// <param name="other">itinerary</param> /// <returns>A merge between the current itinerary and the provided itinerary /// that describes a continuous route even if the cargo is currently misdirected.</returns> public virtual Itinerary ItineraryMergedWith(Itinerary other) { if (RoutingStatus == RoutingStatus.NOT_ROUTED) { return(other); } if (IsMisdirected && TransportStatus == TransportStatus.ONBOARD_CARRIER) { var currentLeg = Leg.DeriveLeg(CurrentVoyage, LastKnownLocation, CurrentVoyage.ArrivalLocationWhenDepartedFrom(LastKnownLocation)); return(Itinerary.TruncatedAfter(LastKnownLocation).WithLeg(currentLeg).AppendBy(other)); } return(Itinerary.TruncatedAfter(EarliestReroutingLocation).AppendBy(other)); }
public bool Equals(IDelivery other) { if (null == other) { return(false); } if (object.ReferenceEquals(this, other)) { return(true); } if (null != CurrentVoyage && !CurrentVoyage.Equals(other.CurrentVoyage)) { return(false); } if (null == CurrentVoyage && null != other.CurrentVoyage) { return(false); } if (null != LastKnownLocation && !LastKnownLocation.Equals(other.LastKnownLocation)) { return(false); } if (null == LastKnownLocation && null != other.LastKnownLocation) { return(false); } if (TransportStatus != other.TransportStatus) { return(false); } if (_routingStatus != other.RoutingStatus) { return(false); } if (IsUnloadedAtDestination != other.IsUnloadedAtDestination) { return(false); } return(true); }