public RoastSchedule(Guid id, DateTime roastWeekStartsOn) { RoastDays = new RoastDays(new HashSet <RoastDay>()); //不仅把event放到集合中,还调用本类的Apply方法 ApplyChange(new RoastScheduleCreatedEvent(id, roastWeekStartsOn)); }
public void SetRoastDays(RoastDays roastDays) { if (roastDays.Days.Count == 0) { throw new ArgumentNullException("roastDays count must be greater than 0"); } var newDays = roastDays.Days.Select(t => t.Day).ToArray(); ApplyChange(new RoastScheduleRoastDayChosenEvent(Id, newDays)); }
// public void Apply(RoastScheduleRoastDayChosenEvent e) { RoastDays = new RoastDays(e.Days); }