public void Save()
        {
            //TODO:atrosin make the method transaction

            Location location = locationRepository.Find(new UnLocode("SESTO"));

            Cargo cargo            = cargoRepository.Find(new TrackingId("XYZ"));
            var   completionTime   = new DateTime(2008, 2, 2);
            var   registrationTime = new DateTime(2008, 3, 3);
            var   evnt             = new HandlingEvent(cargo, completionTime, registrationTime, HandlingType.CLAIM, location);

            handlingEventRepository.Store(evnt);

            Flush();

            IList list = GetPlainHandlingEventListFromDb(evnt);

            Assert.IsNotNull(list, "The object is not inserted");
            Assert.AreEqual(list.Count, 4, "The number of retrivied objects is not as expected");
            Assert.AreEqual(1, list[0] /*CARGO_ID*/);
            Assert.AreEqual(completionTime, list[1] /*COMPLETIONTIME*/);
            Assert.AreEqual(registrationTime, list[2] /*REGISTRATIONTIME*/);
            Assert.AreEqual("CLAIM", list[3] /*TYPE*/);
            // TODO: the rest of the columns
        }
예제 #2
0
        public void RegisterHandlingEvent(DateTime completionTime,
                                          TrackingId trackingId,
                                          VoyageNumber voyageNumber,
                                          UnLocode unLocode,
                                          HandlingType type)
        {
            //TODO: Revise transaciton and UoW logic
            using (var transactionScope = new TransactionScope())
            {
                var registrationTime = new DateTime();

                /* Using a factory to create a HandlingEvent (aggregate). This is where
                 * it is determined wether the incoming data, the attempt, actually is capable
                 * of representing a real handling event. */
                HandlingEvent evnt = handlingEventFactory.CreateHandlingEvent(
                    registrationTime, completionTime, trackingId, voyageNumber, unLocode, type);

                /* Store the new handling event, which updates the persistent
                 * state of the handling event aggregate (but not the cargo aggregate -
                 * that happens asynchronously!)*/

                handlingEventRepository.Store(evnt);

                /* Publish an event stating that a cargo has been handled. */
                applicationEvents.CargoWasHandled(evnt);

                transactionScope.Complete();
            }
            logger.Info("Registered handling event");
        }
        public void RegisterHandlingEvent(DateTime completionTime, TrackingId trackingId, UnLocode unLocode, HandlingEventType type)
        {
            var cargo    = _cargoRepository.Find(trackingId);
            var location = _locationRepository.Find(unLocode);
            var @event   = new HandlingEvent(type, location, DateTime.Now, completionTime, cargo);

            _handlingEventRepository.Store(@event);
        }
예제 #4
0
        public object Handle(RegisterHandlingEventCommand command)
        {
            var trackingId = new TrackingId(command.TrackingId);
            var cargo      = _cargoRepository.Find(trackingId);
            var occuranceLocationUnLocode = new UnLocode(command.OccuranceLocation);
            var occuranceLocation         = _locationRepository.Find(occuranceLocationUnLocode);
            var evnt = new HandlingEvent(command.Type, occuranceLocation, DateTime.Now, command.CompletionTime, cargo);

            _handlingEventRepository.Store(evnt);

            return(null);
        }
        public void Handle(CargoHasBeenAssignedToRouteEvent @event)
        {
            HandlingHistory existing = _repository.LookupHandlingHistoryOfCargo(@event.Source.TrackingId);

            if (existing != null)
            {
                return;
            }
            HandlingHistory handlingHistory = new HandlingHistory(@event.Source.TrackingId);

            _repository.Store(handlingHistory);
        }
예제 #6
0
        protected override void DoHandle(CargoHasBeenAssignedToRouteMessage message)
        {
            TrackingId trackingId = new TrackingId(message.TrackingId);

            HandlingHistory existing = _handlingEventRepository.LookupHandlingHistoryOfCargo(trackingId);

            if (existing != null)
            {
                return;
            }
            HandlingHistory handlingHistory = new HandlingHistory(trackingId);

            _handlingEventRepository.Store(handlingHistory);
        }