private void MakeASnapshot(Guid id)
        {
            var aggregate = FindById(id);

            var snapshot = aggregate.Snapshot();

            _eventStore.AddSnapshot(StreamNameFor(aggregate.Id), snapshot);
        }
Exemplo n.º 2
0
        public async Task Add(TAggregate aggregate)
        {
            var streamName = StreamNameFor(aggregate.Id);

            _eventStore.CreateNewStream(streamName, aggregate.GetUncommittedEvents());
            _eventStore.AddSnapshot <TAggregate>(streamName, aggregate);
            aggregate.MarkEventsAsCommitted();
        }
Exemplo n.º 3
0
        /// <summary>
        /// Saves the snapshot.
        /// </summary>
        /// <param name="snapshot">The snapshot.</param>
        /// <param name="order">The order.</param>
        public void SaveSnapshot(OrderSnapshot snapshot, Order order)
        {
            var previousSnapshot = GetLatestSnapshot(order.Id);

            if (previousSnapshot == null || previousSnapshot.Version < snapshot.Version)
            {
                _eventStore.AddSnapshot(StreamNameFor(order.Id), snapshot);
            }
        }
        /// <summary>
        /// Saves the snapshot.
        /// </summary>
        /// <param name="snapshot">The snapshot.</param>
        /// <param name="cart">The cart.</param>
        public void SaveSnapshot(CartSnapshot snapshot, Cart cart)
        {
            var previousSnapshot = GetLatestSnapshot(cart.Id);

            if (previousSnapshot == null || previousSnapshot.Version < snapshot.Version)
            {
                _eventStore.AddSnapshot(StreamNameFor(cart.Id), snapshot);
            }
        }
Exemplo n.º 5
0
        public void SaveSnapshot(TSnapshot snapshot, TEntity entity)
        {
            var previousSnapshot = GetLatestSnapshot(entity.Id);

            if (previousSnapshot == null || previousSnapshot.Version < snapshot.Version)
            {
                _eventStore.AddSnapshot(StreamNameFor(entity.Id), snapshot);
            }
        }
Exemplo n.º 6
0
        public void SaveSnapshot(BankAccountSnapshot snapshot, BankAccount bankAccount)
        {
            var streamName = StreamFor(bankAccount.Id);

            _eventStore.AddSnapshot(streamName, snapshot);
        }
Exemplo n.º 7
0
        public void SaveSnapshot(PayAsYouGoAccountSnapshot snapshot, PayAsYouGoAccount payAsYouGoAccount)
        {
            var streamName = StreamNameFor(payAsYouGoAccount.Id);

            _eventStore.AddSnapshot <PayAsYouGoAccountSnapshot>(streamName, snapshot);
        }