public void Handle(Cargo.Cargo source, CargoAssignedToRouteEvent @event) { var cargo = _cargoDataAccess.FindByTrackingId(source.TrackingId.IdString); cargo.RouteSpecification = ConvertItineraryToLegDtos(@event.NewItinerary); _cargoDataAccess.Store(cargo); }
/// <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.FindByTrackingId(trackingId); if (c == null) { throw new ArgumentException("Cargo with specified tracking id not found."); } return(c); }
public ActionResult Track(string trackingId) { Reporting.Cargo cargo = _cargoDataAccess.FindByTrackingId(trackingId); if (cargo == null) { ViewData.ModelState.AddModelError("trackingId", "Provided tracking id is invalid."); return(View()); } return(View(new CargoTrackingViewAdapter(cargo))); }
public void Handle(Cargo.Cargo source, CargoDestinationChangedEvent @event) { var cargo = _cargoDataAccess.FindByTrackingId(source.TrackingId.IdString); var spec = @event.NewSpecification; cargo.UpdateRouteSpecification( spec.Origin.CodeString, spec.Destination.CodeString, spec.ArrivalDeadline); _cargoDataAccess.Store(cargo); }
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.FindByTrackingId(trackingId); command.CargoId = cargo.AggregateId; _bus.Send(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.FindByTrackingId(source.TrackingId.IdString); cargo.UpdateHistory( nextExpectedActivity, lastKnownActivity, del.RoutingStatus, del.TransportStatus, del.EstimatedTimeOfArrival, del.IsUnloadedAtDestination, del.IsMisdirected, del.CalculatedAt); _cargoDataAccess.Store(cargo); }