Exemplo n.º 1
0
        public static async Task <OrderAggregate> GetAggregateAsync()
        {
            EventStore.EventStore.RegisterProjection(NumberOfOrders);
            EventStore.EventStore.RegisterProjection(AverageDeliveryTime);

            foreach (var @event in EventStore.EventStore.GetEventPayloads(Guid.NewGuid()))
            {
                EventStore.EventStore.CommitEvent(@event);
            }

            var messages  = EventStore.EventStore.GetEvents();
            var aggregate = new OrderAggregate();

            foreach (var m in messages)
            {
                await aggregate.Apply(m.Payload);
            }

            return(aggregate);
        }