Exemple #1
0
        private void Apply(CreateCustomerCommand cmd)
        {
            var customer = new CustomerAggregateRoot(cmd);

            customer.Lock();

            this.eventStore.AddInstance(customer);
            this.eventStore.AppendChanges(customer.Id);
        }
Exemple #2
0
        /// <summary>
        /// Konstruktor zur Erstellung eines neuen Customer-Aggregates.
        /// </summary>
        public CustomerAggregateRoot([NotNull] CreateCustomerCommand cmd) : base(new CustomerAggregateState(new EventStream(Guid.NewGuid(), new List <IDomainEvent>())))
        {
            if (cmd == null)
            {
                throw new ArgumentNullException("cmd");
            }

            if (string.IsNullOrWhiteSpace(cmd.FirstName))
            {
                throw new ArgumentNullException(cmd.FirstName);
            }

            if (string.IsNullOrWhiteSpace(cmd.LastName))
            {
                throw new ArgumentNullException(cmd.LastName);
            }

            this.Apply(new CustomerCreated(this.Id, cmd.FirstName, cmd.LastName, cmd.Address.Street, cmd.Address.HouseNumber, cmd.Address.PostalCode, cmd.Address.City, this.GetNextVersion(), cmd.CommandId));
        }