public void UpdateTkd(TkdValueObject tkd)
        {
            ApplyChange(new ChannelTkdChangedEvent
            {
                AggregateId = this.AggregateId,

                Timestamp = DateTime.Now,
                Tkd       = tkd
            });
        }
        public ChannelAggregateRoot(Guid aggregateId, string name, string alias, bool connectArea, bool @default, IEnumerable <FieldValueObject> fields, TkdValueObject tkd) : base(aggregateId)
        {
            if (name.IsNullOrEmpty())
            {
                throw new DomainException("频道名不能为空");
            }

            if (alias.IsNullOrEmpty())
            {
                throw new DomainException("url别名不能为空");
            }

            if (fields.GroupBy(x => x.Field).Any(x => x.Count() > 1))
            {
                throw new DomainException("动态字段不能有重复");
            }

            this.ApplyChange(new ChannelCreatedEvent
            {
                AggregateId = this.AggregateId,

                Timestamp   = DateTime.Now,
                Name        = name,
                Alias       = alias,
                ConnectArea = connectArea,
                Default     = @default,
            });

            this.ChangeField(fields);

            this.UpdateTkd(tkd);

            //if (command.DynamicFields != null && command.DynamicFields.Any())
            //    foreach (var x in command.DynamicFields)
            //        this.AppendField(worker, x.Sort, x.Name, x.Field, x.Type, x.SelectValue);
            //else
            //    this.AppendField(worker, -1, "内容", "Content", InputElementType.富文本, null);

            //if (command.Tkd != null)
            //    this.UpdateTkd(worker, command.Tkd.Title, command.Tkd.Keywords, command.Tkd.Description);
        }
 public void Handle(ChannelTkdChangedEvent e)
 {
     this.Tkd      = e.Tkd;
     this.EditDate = e.Timestamp;
 }