public void UpdateClosingPrices(IEnumerable <StockPrice> closingPrices) { var @event = new ClosingPricesAddedEvent(Id, Version, closingPrices.Select(x => new ClosingPricesAddedEvent.ClosingPrice(x.Date, x.Price))); Apply(@event); PublishEvent(@event); }
public void Apply(ClosingPricesAddedEvent @event) { Version++; foreach (var closingPrice in @event.ClosingPrices) { UpdatePrice(closingPrice.Date, closingPrice.Price); } }
public void UpdateClosingPrice(Date date, decimal closingPrice) { var @event = new ClosingPricesAddedEvent(Id, Version, new ClosingPricesAddedEvent.ClosingPrice[] { new ClosingPricesAddedEvent.ClosingPrice(date, closingPrice) }); Apply(@event); PublishEvent(@event); }