jeudi 26 mars 2015

Cqrs Complex commands for master detail tables

I have a CreateUserCommand that responsible for creating accounts.



public class UserCommandHandler : ICommandHandler<CreateUserCommand>
{
private readonly IUserRepository repository;

public UserCommandHandler(IUserRepository repository)
{
this.repository = repository;
}

public void Handle(CreateUserCommand command)
{
User user = new User();
user.Username = command.Username;
user.Password = command.Password;
user.Email = command.Email;

repository.Add(user);
repository.Save();
}
}


But I have UserInRoles Table including (UserId, RoleID) columns. So I have to add user in a role after creation.


How to do this nasted operations with CQRS?


Aucun commentaire:

Enregistrer un commentaire