public static async Task <FetchForAggregateResponse> FetchForAggregate(this IEventStore eventStore, ArtifactId aggregateRootId, EventSourceId eventSourceId, Dolittle.Runtime.Execution.ExecutionContext executionContext) { var response = await eventStore.FetchAggregateEvents(new FetchForAggregateRequest { CallContext = new CallRequestContext { ExecutionContext = executionContext.ToProtobuf() }, Aggregate = new Aggregate { AggregateRootId = aggregateRootId.ToProtobuf(), EventSourceId = eventSourceId } }, CancellationToken.None); return(response); }
public static async Task <CommitEventsResponse> Commit(this IEventStore eventStore, UncommittedEvents events, Dolittle.Runtime.Execution.ExecutionContext executionContext) { var request = new CommitEventsRequest { CallContext = new CallRequestContext { ExecutionContext = executionContext.ToProtobuf() } }; request.Events.AddRange(events.Select(_ => new UncommittedEventContract { Content = _.Content, Public = _.Public, EventType = _.Type.ToProtobuf(), EventSourceId = _.EventSource })); var response = await eventStore.CommitEvents(request, CancellationToken.None).ConfigureAwait(false); return(response); }