public async Task <IEnumerable <DomainEventResult> > AppendAsync( IEnumerable <IDomainEvent> events, CancellationToken token = default) { if (events.IsEmpty()) { return(Enumerable.Empty <DomainEventResult>()); } var results = new List <DomainEventResult>(); foreach (var @event in events) { _dict.AddOrUpdate(@event.AggregateRootId, new List <IDomainEvent>() { @event }, (key, oldValue) => { oldValue.Add(@event); return(oldValue); }); results.Add(DomainEventResult.StorageSucceed(@event.Id)); } return(await Task.FromResult(results)); }
public async Task <DomainEventResult> AppendAsync( IDomainEvent @event, CancellationToken token = default) { if (@event == null) { return(await Task.FromResult(DomainEventResult.StorageSucceed(@event.Id))); } _dict.AddOrUpdate(@event.AggregateRootId, new List <IDomainEvent>() { @event }, (key, oldValue) => { oldValue.Add(@event); return(oldValue); }); return(await Task.FromResult(DomainEventResult.StorageSucceed(@event.Id))); }