采用标准登记程序:
我说的问题是:
的ActivateAccountCommand。
如何加载用户帐户以激活域中的用户帐户?
最初,我希望将新用户Acount.Id传递给readmodel,但在CommandExecutorBase中没有访问(据我所知)--我们不保存以下内容:
protected override void ExecuteInContext(IUnitOfWorkContext context,
CreateAccountViaFormRegistrationCommand command)
{
var newKey = Guid.NewGuid().ToString();
var newAccount = new Account(
command.UserName, command.Email, command.Password, newKey);
SendWelcomeEmail(command.Email, command.UserName, newKey);
context.Accept();
} 发布于 2011-11-16 14:21:24
您可以发布一个AccountActivationKeySent事件,然后可以处理该事件,以填充读取端所需的任何投影。与…有关的东西:
// 1. Create and send the command from your client:
var command = new CreateAccountViaFormRegistrationCommand {
AccountId = Guid.NewGuid(),
...
}
// 2. Create a new account in your command handler
var newAccount = new Account(command.AccountId, ...);
context.Accept();
// 3. And your account constructor (assuming it's inheriting from one
// of EventSource's subclasses, e.g. AggregateRootMappedByConvention)
// might look like this:
public Account(Guid accountId, string name, ...) {
EventSourceId = accountId;
ApplyEvent(new AccountCreated { AccountId = Id, ... } );
ApplyEvent(new AccountActivationSent { AccountId = Id, ... })
}https://stackoverflow.com/questions/8143729
复制相似问题