public BannerItem AddItem(BannerItemAddCommand command) { if (BannerItems == null) { BannerItems = new List <BannerItem>(); } BannerItem bannerItem = new BannerItem(); bannerItem.Init(command); BannerItems.Add(bannerItem); AddEvent(this.ToAddOrChangCacheEvent()); return(bannerItem); }
public BannerItem ChangeItem(BannerItemChangeCommand command) { if (BannerItems == null) { BannerItems = new List <BannerItem>(); } BannerItem bannerItem = BannerItems.FirstOrDefault(p => p.Id == command.Id); if (bannerItem == null) { throw new Exception("BannerItem not found."); } bannerItem.Change(command); AddEvent(this.ToAddOrChangCacheEvent()); return(bannerItem); }