Пример #1
0
        /// <summary>
        /// Account name changed event handler
        /// </summary>
        /// <param name="event">Account renamed event</param>
        public void Handle(AccountNameChanged @event)
        {
            var account = this.accountListItemRepository.Find(@event.AggregateId);

            if (account == null)
            {
                throw new InvalidOperationException("Account list item with id " + @event.AggregateId.ToString() + " was not found in repository.");
            }

            account.Name = @event.Name;
            this.accountListItemRepository.Save(account);
        }
Пример #2
0
        /// <summary>
        /// Account name changed event handler
        /// </summary>
        /// <param name="e">Account renamed event</param>
        public void Handle(AccountNameChanged e)
        {
            var account = this.repository.Find(e.AggregateId);

            if (account == null)
            {
                throw new InvalidOperationException("Account with id " + e.AggregateId.ToString() + " was not found in repository.");
            }

            account.SetName(e.Name);
            this.repository.Save(account);
        }
Пример #3
0
        public void AccountNameChangedSerialisationRoundtripHasAllFields()
        {
            const string AccountName = "Account name";

            var accountNameChanged = new AccountNameChanged(AccountName);
            var roundtripped       = this.SerialisationRoundtrip(accountNameChanged);

            Assert.AreNotSame(accountNameChanged, roundtripped);

            Assert.AreEqual(accountNameChanged.Name, roundtripped.Name);

            this.AssertDomainEventPropertiesAreEqual(accountNameChanged, roundtripped);
        }
Пример #4
0
        /// <summary>
        /// Account name changed event handler
        /// </summary>
        /// <param name="e">Account renamed event</param>
        public void Handle(AccountNameChanged e)
        {
            // Only update account list item
            var account = this.accountListItemRepository.Find(e.AccountId);

            if (account == null)
            {
                throw new InvalidOperationException("Account list item with id " + e.AccountId.ToString() + " was not found in repository.");
            }

            account.SetName(e.Name);
            this.accountListItemRepository.Save(account);
        }
Пример #5
0
 /// <summary>
 /// Handles <see cref="AccountNameChanged"/> events
 /// </summary>
 /// <param name="e">Event to handle</param>
 private void When(AccountNameChanged e)
 {
     this.Name = e.Name;
 }
Пример #6
0
 /// <summary>
 /// Handles <see cref="AccountNameChanged"/> events
 /// </summary>
 /// <param name="e">Event to handle</param>
 private void When(AccountNameChanged e)
 {
     this.Name = e.Name;
 }
Пример #7
0
 public void Apply(AccountNameChanged message)
 {
     Name = message.Name;
 }