public IEnumerable <Itinerary> requestPossibleRoutesForCargo(TrackingId trackingId) { var cargo = _cargoRepository.find(trackingId); if (cargo == null) { return(new List <Itinerary>()); } return(_routingService.fetchRoutesForSpecification(cargo.RouteSpecification)); }
public void testFindByCargoId() { TrackingId trackingId = new TrackingId("FGH"); Cargo cargo = cargoRepository.find(trackingId); Assert.AreEqual(SampleLocations.HONGKONG, cargo.RouteSpecification.Origin); Assert.AreEqual(SampleLocations.HELSINKI, cargo.RouteSpecification.Destination); IEnumerable <HandlingEvent> events = HandlingEventRepository.lookupHandlingHistoryOfCargo(cargo).distinctEventsByCompletionTime(); Assert.AreEqual(2, events.Count()); HandlingEvent firstEvent = events.ElementAt(0); assertHandlingEvent(cargo, firstEvent, HandlingActivityType.RECEIVE, SampleLocations.HONGKONG, 100, 160, Voyage.None); HandlingEvent secondEvent = events.ElementAt(1); Voyage hongkongMelbourneTokyoAndBack = new Voyage.Builder(new VoyageNumber("0303"), SampleLocations.HONGKONG).addMovement(SampleLocations.MELBOURNE, new DateTime(1), new DateTime(2)).addMovement(SampleLocations.TOKYO, new DateTime(3), new DateTime(4)).addMovement(SampleLocations.HONGKONG, new DateTime(5), new DateTime(6)).build(); assertHandlingEvent(cargo, secondEvent, HandlingActivityType.LOAD, SampleLocations.HONGKONG, 150, 110, hongkongMelbourneTokyoAndBack); IEnumerable <Leg> legs = cargo.Itinerary.Legs; Assert.AreEqual(3, legs.Count()); Leg firstLeg = legs.ElementAt(0); assertLeg(firstLeg, "0101", SampleLocations.HONGKONG, SampleLocations.MELBOURNE); Leg secondLeg = legs.ElementAt(1); assertLeg(secondLeg, "0101", SampleLocations.MELBOURNE, SampleLocations.STOCKHOLM); Leg thirdLeg = legs.ElementAt(2); assertLeg(thirdLeg, "0101", SampleLocations.STOCKHOLM, SampleLocations.HELSINKI); }
public void reportCargoUpdate(TrackingId trackingId) { Cargo cargo = cargoRepository.find(trackingId); CargoDetails cargoDetails = assembleFrom(cargo); reportSubmission.submitCargoDetails(cargoDetails); }
private Cargo findCargo(TrackingId trackingId) { var cargo = cargoRepository.find(trackingId); if (cargo == null) { throw new UnknownCargoException(trackingId); } return(cargo); }
public void alertIfReadyToClaim(TrackingId trackingId) { var cargo = cargoRepository.find(trackingId); if (cargo.IsReadyToClaim) { // At this point, a real system would probably send an email or SMS // or something, but we simply log a message. LOG.Info("Cargo " + cargo + " is ready to be claimed"); } }
public void alertIfMisdirected(TrackingId trackingId) { var cargo = cargoRepository.find(trackingId); if (cargo.IsMisdirected) { /** * In a real system, some significant action would be taken * when this happens. */ LOG.Info("Cargo " + cargo + " is misdirected!"); } }
public ActionResult Track(string id) { var trackingId = new TrackingId(id); var cargo = _cargoRepository.find(trackingId); if (cargo == null) { ModelState.AddModelError("trackingId", "Unknown tracking id"); return(View()); } var handlingEvents = _handlingEventRepository .lookupHandlingHistoryOfCargo(cargo) .distinctEventsByCompletionTime(); var model = BuildCargoTrackingViewModel(cargo, handlingEvents); return(View(model)); }