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); }
private static Value UpdateValue(Value value, JourneyCreatedEvent @event) { return(new Value( value.JourneyCount + 1, value.JourneyDistance + @event.RouteDistance, value.LiftCount, value.LiftDistance)); }
private Journey ToDto(JourneyCreatedEvent journey) { var lifts = _lifts.GetOrDefault(journey.JourneyId); return(new Journey( journey.JourneyId, journey.DateOfOccurrence, journey.RouteDistance, lifts.Select(ToDto).ToList())); }
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)); } }
public void Update(JourneyCreatedEvent @event) { _journeys.Add(@event); }