Microservices
- Identity
- Api
- Application
- Interfaces
- IUserService.cs
- Services
- UserService.cs
- Interfaces
- Data
- Domain
- CommandHandlers
- CreateUserCommandHandler.cs
- Commands
- CreateUserCommand.cs
- Interfaces
- IUserRepository.cs
- Events
- CommandHandlers
Following this approach I cannot inject IUserService interface into my CreateUserCommandHandler (circular ref). Obviously this is not right way, how would you restructure this folder organization?
public class CreateUserCommandHandler : IRequestHandler<CreateUserCommand, bool>
{
private readonly IEventBus _bus;
// private readonly IUserService _userService; cannot access this
public CreateUserCommandHandler(IEventBus bus)
{
_bus = bus;
}
public Task<bool> Handle(CreateUserCommand request, CancellationToken cancellationToken)
{
_bus.Publish(new UserCreatedEvent(request.Name, request.Email));
return Task.FromResult(true);
}
}