Esempio n. 1
0
        public void Complete()
        {
            foreach (var change in _account.Changes())
            {
                EventStore.Add(change);
            }

            AccountStore.Update(_state.ToStorage());
        }
        public void Handle(AddCreditCardCommand command)
        {
            var state = AccountState.FromStorage(AccountStore.AccountStates.SingleOrDefault(x => x.Email == command.Email));

            if (state == null)
            {
                throw new Exception("Not found");
            }

            var agg = Domain.Account.Create(state);

            agg.AddCreditCard(command.CreditCard);

            foreach (var change in agg.Changes())
            {
                EventStore.Add(change);
            }

            AccountStore.Update(state.ToStorage());
        }