Exemple #1
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);
        }
Exemple #2
0
 private static Value UpdateValue(Value value, JourneyCreatedEvent @event)
 {
     return(new Value(
                value.JourneyCount + 1,
                value.JourneyDistance + @event.RouteDistance,
                value.LiftCount,
                value.LiftDistance));
 }
Exemple #3
0
        private Journey ToDto(JourneyCreatedEvent journey)
        {
            var lifts = _lifts.GetOrDefault(journey.JourneyId);

            return(new Journey(
                       journey.JourneyId,
                       journey.DateOfOccurrence,
                       journey.RouteDistance,
                       lifts.Select(ToDto).ToList()));
        }
Exemple #4
0
        public void Update(JourneyCreatedEvent @event)
        {
            _journeys.Add(@event);
            var journeysOnDateOfOccurence = _journeysByDate.GetOrAdd(@event.DateOfOccurrence, () => new HashSet <JourneyCreatedEvent>());

            journeysOnDateOfOccurence.Add(@event);
            var dateOfOccurrence = @event.DateOfOccurrence;

            foreach (var factEntry in _facts.Retrieve().Where(f => f.Key.Day.DayOfMonth == dateOfOccurrence.Day && f.Key.Month.MonthOfYear == dateOfOccurrence.Month && f.Key.Month.Year == dateOfOccurrence.Year).ToList())
            {
                _facts.Set(factEntry.Key, UpdateValue(factEntry.Value, @event));
            }
        }
Exemple #5
0
 public void Update(JourneyCreatedEvent @event)
 {
     _journeys.Add(@event);
 }