public async Task CommitChangesAsync(TypedEventStreamCommit eventStreamForCommit) { byte[] revisionData = this.EventsSerializer.Serialize(eventStreamForCommit.Changes); byte[] metadata = this.MetadataSerializer.Serialize(eventStreamForCommit.Metadata); EventStreamCommit commit = new EventStreamCommit(eventStreamForCommit.AggregateId, eventStreamForCommit.AggregateType, eventStreamForCommit.WorkingCopyVersion, eventStreamForCommit.CorrelationId, eventStreamForCommit.CausationId, this.MetadataSerializer.ContentType, this.MetadataSerializer.ContentEncoding, metadata, this.EventsSerializer.ContentType, this.EventsSerializer.ContentEncoding, revisionData); await this.EventStore.CommitChangesAsync(commit); }
public async Task CommitChangesAsync(EventStreamCommit commit) { Revision storedRevision = new Revision() { AggregateId = commit.AggregateId, AggregateType = commit.AggregateType.ToString(), CorrelationId = commit.CorrelationId, CausationId = commit.CausationId, MetadataContentType = commit.MetadataContentType, MetadataContentEncoding = commit.MetadataContentEncoding, Metadata = commit.Metadata, ChangesContentType = commit.ChangesContentType, ChangesContentEncoding = commit.ChangesContentEncoding, Changes = commit.Changes, OccurrenceDate = DateTime.UtcNow, RevisionId = (commit.WorkingCopyVersion < 0) ? 0 : commit.WorkingCopyVersion + 1 }; DbContext.StoredRevisions.Add(storedRevision); await Task.CompletedTask; }