private void StoreEventStoreData(EventStoreData eventStoreData) { using (var documentClient = new DocumentClient(new Uri(_config.Uri), _config.Key)) { var collectionUri = UriFactory.CreateDocumentCollectionUri(_config.Database, _config.Collection); documentClient.CreateDocumentAsync(collectionUri, eventStoreData).GetAwaiter().GetResult(); } }
public void SaveSnapshot(AggregateRoot aggregate) { var eventStoreData = new EventStoreData { EventIndex = aggregate.EventIndex, AggregateId = $"{aggregate.Id}_aggregate", EventType = aggregate.GetType().Name, Body = JsonConvert.SerializeObject(aggregate) }; StoreEventStoreData(eventStoreData); }
public void Save(AggregateRoot aggregate) { var newEvents = aggregate.Changes; var aggregateId = aggregate.Id; foreach (var @event in newEvents) { var eventStoreData = new EventStoreData { EventIndex = @event.Index, AggregateId = aggregateId, EventType = @event.GetType().Name, Body = JsonConvert.SerializeObject(@event) }; StoreEventStoreData(eventStoreData); } }