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); }
public void Replay(PersonCreatedEvent @event) { var personId = @event.PersonId; var person = new Person(personId, @event.PersonName, _eventPublisher); _repositories.Store(person); }
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); }
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); }