public Task <Nothing> AppendAsync(AggregateId aggregateId, IReadOnlyList <IDomainEvent> domainEvents, long expectedVersion) { if (!_domainEventsPerAggregate.TryGetValue(aggregateId.ToPureAggregateId(), out var aggregateDomainEvents)) { aggregateDomainEvents = new List <IDomainEvent>(); _domainEventsPerAggregate.Add(aggregateId.ToPureAggregateId(), aggregateDomainEvents); } PreventAppendIfExpectedVersionDoesntMatchWithNumberOfPreviouslyAppliedEventsForAggregate( aggregateId.ToPureAggregateId(), expectedVersion, aggregateDomainEvents); aggregateDomainEvents.AddRange(domainEvents); _allDomainEvents.AddRange(domainEvents); return(Task.FromResult(NotAtAll)); }
public Task <IReadOnlyList <IDomainEvent> > AsyncLoadAllEventsFor(AggregateId aggregateId) { if (!_domainEventsPerAggregate.TryGetValue(aggregateId.ToPureAggregateId(), out var aggregateDomainEvents)) { aggregateDomainEvents = new List <IDomainEvent>(); } return(Task.FromResult(aggregateDomainEvents as IReadOnlyList <IDomainEvent>)); }