Ejemplo n.º 1
0
 /// <summary>
 /// Loads DTO of cargo for cargo routing function.
 /// </summary>
 /// <param name="trackingId">Cargo tracking id.</param>
 /// <returns>DTO.</returns>
 public Reporting.Cargo LoadCargoForRouting(string trackingId)
 {
     Reporting.Cargo c = _cargoDataAccess.Find(trackingId);
     if (c == null)
     {
         throw new ArgumentException("Cargo with specified tracking id not found.");
     }
     return(c);
 }
        public void Handle(Cargo.Cargo source, CargoDestinationChangedEvent @event)
        {
            var cargo = _cargoDataAccess.Find(source.Id);
            var spec  = @event.NewSpecification;

            cargo.UpdateRouteSpecification(
                spec.Origin.CodeString,
                spec.Destination.CodeString,
                spec.ArrivalDeadline);
        }
Ejemplo n.º 3
0
 public ActionResult Track(string trackingId)
 {
     Reporting.Cargo cargo = _cargoDataAccess.Find(trackingId);
     if (cargo == null)
     {
         ViewData.ModelState.AddModelError("trackingId", "Provided tracking id is invalid.");
         return(View());
     }
     return(View(new CargoTrackingViewAdapter(cargo)));
 }
        protected override void DoHandle(CargoHandledMessage message)
        {
            HandlingActivity lastKnownActivity    = new HandlingActivity((HandlingEventType)message.LastKnownEventType, message.LastKnownLocation);
            HandlingActivity nextExpectedActivity = null;

            if (message.NextExpectedEventType.HasValue && message.NextExpectedLocation != null)
            {
                nextExpectedActivity = new HandlingActivity((HandlingEventType)message.NextExpectedEventType, message.NextExpectedLocation);
            }
            Cargo cargo = _cargoDataAccess.Find(message.TrackingId);

            cargo.UpdateHistory(
                nextExpectedActivity,
                lastKnownActivity,
                (RoutingStatus)message.RoutingStatus,
                (TransportStatus)message.TransportStatus,
                message.EstimatedTimeOfArrival,
                message.IsUnloaded,
                message.IsMisdirected,
                message.CalculatedAt);
        }
Ejemplo n.º 5
0
 public ActionResult RegisterHandlingEvent(string trackingId, RegisterHandlingEventCommand command)
 {
     if (command.CompletionTime == DateTime.MinValue)
     {
         ModelState.AddModelError("command.CompletionTime", "Event completion date is required and must be a valid date.");
     }
     if (string.IsNullOrEmpty(trackingId))
     {
         ModelState.AddModelError("trackingId", "Tracking id must be specified.");
     }
     if (!ModelState.IsValid)
     {
         AddHandlingLocations();
         AddHandlingEventTypes();
         return(View());
     }
     Reporting.Cargo cargo = _cargoDataAccess.Find(trackingId);
     command.CargoId = cargo.Id;
     _bus.Publish(command);
     return(RedirectToAction("Index", "Home"));
 }
        public void Handle(Cargo.Cargo source, CargoHandledEvent @event)
        {
            var del = @event.Delivery;
            var lastKnownActivity = new Reporting.HandlingActivity(del.LastEventType.Value, del.LastKnownLocation.CodeString);

            Reporting.HandlingActivity nextExpectedActivity = null;
            if (del.NextExpectedActivity != null)
            {
                nextExpectedActivity = new Reporting.HandlingActivity(del.NextExpectedActivity.EventType, del.NextExpectedActivity.Location.CodeString);
            }
            var cargo = _cargoDataAccess.Find(source.Id);

            cargo.UpdateHistory(
                nextExpectedActivity,
                lastKnownActivity,
                del.RoutingStatus,
                del.TransportStatus,
                del.EstimatedTimeOfArrival,
                del.IsUnloadedAtDestination,
                del.IsMisdirected,
                del.CalculatedAt);
        }
        public void Handle(Cargo.Cargo source, CargoAssignedToRouteEvent @event)
        {
            var cargo = _cargoDataAccess.Find(source.Id);

            cargo.RouteSpecification = ConvertItineraryToLegDtos(@event.NewItinerary);
        }
        protected override void DoHandle(CargoDestinationChangedMessage message)
        {
            Cargo cargo = _cargoDataAccess.Find(message.TrackingId);

            cargo.UpdateRouteSpecification(message.Origin, message.Destination, message.ArrivalDeadline);
        }
        protected override void DoHandle(CargoAssignedToRouteMessage message)
        {
            Cargo cargo = _cargoDataAccess.Find(message.TrackingId);

            cargo.RouteSpecification = message.Legs;
        }