public async Task SaveAsync(TAggregate aggregate)
        {
            IEventSourcingAggregate <TAggregateId> aggregatePersistence = aggregate;

            foreach (var @event in aggregatePersistence.GetUncommittedEvents())
            {
                await eventStore.AppendEventAsync(@event);
            }
            aggregatePersistence.ClearUncommittedEvents();
        }
Beispiel #2
0
        public async Task SaveAsync(TAggregate aggregate)
        {
            foreach (var domainEvent in aggregate.GetUncommittedEvents())
            {
                await _eventStore.AppendEventAsync(domainEvent);

                await _publisher.PublishAsync((dynamic)domainEvent);
            }

            aggregate.ClearUncommittedEvents();
        }
Beispiel #3
0
        public async Task SaveAsync(Starship aggregate, CancellationToken cancellationToken)
        {
            await _elasticClient.IndexAsync(aggregate, g => g.Index(DEFAULT_INDEX).Id(aggregate.Id), cancellationToken);

            var evts = aggregate.GetUncommittedEvents();

            if (evts.Any())
            {
                await _eventStore.AppendEventAsync(evts, cancellationToken);

                aggregate.ClearUncommittedEvents();
            }
        }
Beispiel #4
0
        public async Task Save(TAggregate aggregate)
        {
            try
            {
                foreach (var @event in aggregate.GetUncommittedEvents())
                {
                    await eventStore.AppendEventAsync(@event);

                    //await publisher.PublishAsync((dynamic)@event);
                }
                aggregate.ClearUncommittedEvents();
            }
            catch (EventStoreCommunicationException ex)
            {
                //throw new RepositoryException("Unable to access persistence layer", ex);
                throw;
            }
        }
        public async Task SaveAsync(TAggregate aggregate)
        {
            try
            {
                IEventSourcingAggregate <TAggregateId> aggregatePersistence = aggregate;

                foreach (var @event in aggregatePersistence.GetUncommittedEvents())
                {
                    await eventStore.AppendEventAsync(@event);

                    await publisher.PublishAsync(@event);
                }
                aggregatePersistence.ClearUncommittedEvents();
            }
            catch (EventStoreCommunicationException ex)
            {
                throw new RepositoryException("Unable to access persistence layer", ex);
            }
        }
Beispiel #6
0
 /// <summary>
 /// Appends the event model
 /// </summary>
 /// <returns>The aggregate model</returns>
 /// <param name="eventModel">Event source model.</param>
 public async Task <int> AppendEventAsync(IModelEvent <IdT> eventModel)
 {
     return(await _eventStore.AppendEventAsync(eventModel));
 }