public void Handle(ProductDescriptionChangedEvent @event) { try { EventStore.Save(@event); } catch { throw; } }
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); } }
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; } }