public void SetRelativeNTAs(Date date, IEnumerable <decimal> percentages) { if (!IsEffectiveAt(date)) { throw new EffectiveDateException(String.Format("Stock not active at {0}", date)); } var percentagesArray = percentages.ToArray(); if (percentagesArray.Length != _ChildSecurities.Length) { throw new ArgumentException(String.Format("Expecting {0} values but received {1}", _ChildSecurities.Length, percentagesArray.Length)); } var total = percentagesArray.Sum(); if (total != 1.00m) { throw new ArgumentException(String.Format("Total percentage must add up to 1.00 but was {0}", total)); } var @event = new RelativeNTAChangedEvent(Id, Version, date, percentagesArray); Apply(@event); PublishEvent(@event); }
public void Apply(RelativeNTAChangedEvent @event) { Version++; _RelativeNTAs.Change(@event.Date, new RelativeNTA(@event.Percentages)); }