예제 #1
0
 public void Handle(ProductDescriptionChangedEvent @event)
 {
     try
     {
         EventStore.Save(@event);
     }
     catch
     {
         throw;
     }
 }
예제 #2
0
        public void UndoEvent()
        {
            Console.WriteLine("Undoing event: ");

            ProductDescriptionChangedEvent lastEvent = Events.LastOrDefault() as ProductDescriptionChangedEvent;

            if (lastEvent != null)
            {
                Command(new ChangeProductDescriptionCommand(lastEvent.Target, lastEvent.OldDescription, false));
                Events.Remove(lastEvent);
            }
        }
예제 #3
0
        public async Task ChangeProductDescription(Guid productId, string description)
        {
            try
            {
                var product = await Repository.GetByKeyAsync <Product>(productId);

                product.ChangeDescription(description);

                await Repository.SaveChangesAsync();

                var @event = new ProductDescriptionChangedEvent(productId, description);
                EventBus.RaiseEvent(@event);
            }
            catch
            {
                throw;
            }
        }