Permalink
Browse files

CommandBus now Dispatches instead of Publishes

  • Loading branch information...
1 parent c0b8167 commit 629a856a14d47fd9d2f26ce6b74ae2e8a5704421 @andlju committed Sep 23, 2011
View
4 Source/Taskmaster.Service/Bus/ICommandBus.cs
@@ -6,15 +6,15 @@ namespace Taskmaster.Service.Bus
{
public interface ICommandBus
{
- void Publish<T>(T command);
+ void Dispatch<T>(T command);
void RegisterHandler<T>(ICommandHandler<T> handler);
}
public class CommandBus : ICommandBus
{
private readonly Dictionary<Type, object> _handlers = new Dictionary<Type, object>();
- public void Publish<T>(T command)
+ public void Dispatch<T>(T command)
{
var type = typeof (T);
var handler = (ICommandHandler<T>)_handlers[type];
View
6 Source/Taskmaster.Service/TaskService.cs
@@ -33,7 +33,7 @@ public AddTaskItemResponse AddTaskItem(AddTaskItemRequest request)
Guid? assignedUserAggregateId = GetUserAggregateId(request.AssignedToUserId);
- _commandBus.Publish(new AddTaskItemCommand(GetUserAggregateId(request.RequestUserId).Value, taskItemAggregateId, request.Title, request.Details, assignedUserAggregateId));
+ _commandBus.Dispatch(new AddTaskItemCommand(GetUserAggregateId(request.RequestUserId).Value, taskItemAggregateId, request.Title, request.Details, assignedUserAggregateId));
int taskItemModelId = _identityLookup.GetModelId<Domain.TaskItem>(taskItemAggregateId);
@@ -50,7 +50,7 @@ public EditTaskItemResponse EditTaskItem(EditTaskItemRequest request)
Guid? assignedUserAggregateId = GetUserAggregateId(request.AssignedToUserId);
- _commandBus.Publish(new EditTaskItemCommand(GetUserAggregateId(request.RequestUserId).Value, taskItemAggregateId, request.Title, request.Details, assignedUserAggregateId));
+ _commandBus.Dispatch(new EditTaskItemCommand(GetUserAggregateId(request.RequestUserId).Value, taskItemAggregateId, request.Title, request.Details, assignedUserAggregateId));
return new EditTaskItemResponse()
{
@@ -64,7 +64,7 @@ public AddCommentResponse AddComment(AddCommentRequest request)
Guid taskItemAggregateId = _identityLookup.GetAggregateId<Domain.TaskItem>(request.TaskItemId);
Guid commentId = Guid.NewGuid();
- _commandBus.Publish(new AddCommentCommand(GetUserAggregateId(request.RequestUserId).Value, taskItemAggregateId, commentId, request.Comment));
+ _commandBus.Dispatch(new AddCommentCommand(GetUserAggregateId(request.RequestUserId).Value, taskItemAggregateId, commentId, request.Comment));
int commentModelId = _identityLookup.GetModelId<Domain.TaskComment>(commentId);
View
2 Source/Taskmaster.Service/UserService.cs
@@ -27,7 +27,7 @@ public AddUserResponse AddUser(AddUserRequest request)
{
var userAggregateId = Guid.NewGuid();
- _commandBus.Publish(new AddUserCommand(GetUserAggregateId(request.RequestUserId).Value, userAggregateId, request.Name));
+ _commandBus.Dispatch(new AddUserCommand(GetUserAggregateId(request.RequestUserId).Value, userAggregateId, request.Name));
var userModelId = _identityLookup.GetModelId<Domain.User>(userAggregateId);

0 comments on commit 629a856

Please sign in to comment.