Exemplo n.º 1
0
        /// <summary>
        /// Adds the specified aggregate root.
        /// </summary>
        /// <param name="aggregateRoot">The aggregate root.</param>
        public void Add(AggregateRoot aggregateRoot)
        {
            ResolveConcurrencyConflicts(aggregateRoot);

            IEnumerable <IEvent> events = store.Save(aggregateRoot);

            if (ShouldCreateSnapshot(aggregateRoot))
            {
                store.SaveShapShot(aggregateRoot);
            }

            eventBus.Publish(events);

            aggregateRoot.AcceptChanges();
        }
        public void Save(AggregateRoot aggregateRoot)
        {
            var events = aggregateRoot.GetUncommittedEvents();

            _store.Save(aggregateRoot);

            if (ShouldCreateSnapshot(aggregateRoot))
            {
                _snapshotStore.SaveSnapshot(aggregateRoot);
            }

            _eventBus.Publish(events.Cast <IEvent>());

            // Accept the changes.
            aggregateRoot.AcceptChanges();
        }
Exemplo n.º 3
0
        public void Save(AggregateRoot aggregateRoot)
        {
            var events = aggregateRoot.GetUncommittedEvents();

            _store.Save(aggregateRoot);
            _eventBus.Publish(events);
            // TODO: Snapshot should not effect saving.
            if (ShouldCreateSnapshot(aggregateRoot))
            {
                var snapshot = GetSnapshot(aggregateRoot);

                if (snapshot != null)
                {
                    _snapshotStore.SaveShapshot(snapshot);
                }
            }
            aggregateRoot.AcceptChanges();
        }