private void RaiseValidation()
 {
     foreach (var evt in source.GetEvents())
     {
         this.validationBus.RaiseEvent(evt);
     }
 }
Example #2
0
        public override void Load(IEventSource <IProductEvent> eventSource)
        {
            foreach (var ev in eventSource.GetEvents().OrderBy(e => e.AggregateOrdinal).Where(p => p.AggregateId == ProductId))
            {
                AggregateOrdinal = ev.AggregateOrdinal;

                var productAdded = ev as ProductAddedEvent;
                if (productAdded != null)
                {
                    Name     = productAdded.Name;
                    Quantity = productAdded.InititalQuantity;
                    Price    = productAdded.Price;
                }

                var productPriceChanged = ev as ProductPriceChangedEvent;
                if (productPriceChanged != null)
                {
                    Price = productPriceChanged.NewPrice;
                }

                var ProductNameChanged = ev as ProductNameChangedEvent;
                if (ProductNameChanged != null)
                {
                    Name = ProductNameChanged.NewName;
                }

                var productQuantityAdded = ev as ProductQuantityAddedEvent;
                if (productQuantityAdded != null)
                {
                    Quantity += productQuantityAdded.AdditionalQuantity;
                }
            }
        }
 private void RaiseValidation(IEventSource source)
 {
     if (source == null)
     {
         throw new ArgumentNullException("source");
     }
     foreach (var evt in source.GetEvents())
     {
         this.validationBus.RaiseEvent(evt);
     }
 }
        private void RaiseEvents(IEventSource source)
        {
            if (source == null)
            {
                throw new ArgumentNullException("source");
            }
            foreach (var evt in source.GetEvents())
            {
                this.eventBus.RaiseEvent(evt);
            }

            source.Clear();
        }