/// <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); }
/// <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); }
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); }
/// <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); }
/// <summary> /// Handles <see cref="AccountNameChanged"/> events /// </summary> /// <param name="e">Event to handle</param> private void When(AccountNameChanged e) { this.Name = e.Name; }
public void Apply(AccountNameChanged message) { Name = message.Name; }