public async Task SaveChanges()
 {
     foreach (var s in snapshots)
     {
         await snapshotStore.Store(s);
     }
 }
Пример #2
0
        public async Task Save(MessageContext messageContext, IAggregate aggregate)
        {
            var storables = aggregate.Events
                            .Select(x =>
                                    new StorableMessage(
                                        new Metadata(messageContext.AggregateId, messageContext.ProcessCode, messageContext.ProcessId, DateTime.Now),
                                        x));
            var stream = new Stream(Categories.Events, aggregate.GetType(), messageContext.AggregateId);
            await messageStore.Store(stream, aggregate.Version, storables);

            // TODO: Try catch
            await snapshotStore.Store(
                new Snapshot(messageContext.AggregateId, aggregate.Version, aggregate.RootObject));
        }