コード例 #1
0
        public void Execute(AddJourneyWithLiftsCommand command)
        {
            var routeDistance = new Distance(command.RouteDistance, DistanceUnit.Kilometer);
            var journey       = new Journey(command.JourneyId, command.DateOfOccurrence, routeDistance, _eventPublisher);

            foreach (var lift in command.Lifts)
            {
                var liftDistance = new Distance(lift.LiftDistance, DistanceUnit.Kilometer);
                var personId     = GetOrAddPersonWithName(lift.PersonName);
                journey = journey.AddLift(personId, liftDistance);
            }
            _repositories.Store(journey);
        }
コード例 #2
0
        public void Replay(PersonCreatedEvent @event)
        {
            var personId = @event.PersonId;
            var person   = new Person(personId, @event.PersonName, _eventPublisher);

            _repositories.Store(person);
        }
コード例 #3
0
        public void Replay(JourneyCreatedEvent @event)
        {
            var routeDistance = new Distance(@event.RouteDistance, DistanceUnit.Kilometer);
            var journey       = new Journey(@event.JourneyId, @event.DateOfOccurrence, routeDistance, _eventPublisher);

            _journeyRepository.Store(journey);
        }
コード例 #4
0
        public void Replay(LiftAddedEvent @event)
        {
            var liftDistance = new Distance(@event.LiftDistance, DistanceUnit.Kilometer);
            var journey      = _repositories
                               .Get <Journey>(@event.JourneyId)
                               .AddLift(@event.PersonId, liftDistance);

            _repositories.Store(journey);
        }