public static void RegisterCommands(ConstrutorDeControllersComDependencias dependencias) { var bus = new CommandBus(); var repositorioDeClientes = new RepositorioDeClientes(); var repositorioDePedidos = new RepositorioDePedidos(); var repositorioDeProdutos = new RepositorioDeProdutos(); bus.Register <AdicionarCliente>(new AdicionarClienteHandler(repositorioDeClientes).Handle); bus.Register <AdicionarPedido>(new AdicionarPedidoHandler(repositorioDeClientes, repositorioDePedidos, repositorioDeProdutos).Handle); dependencias.Add <ICommandSender>(bus); }
public async Task <IEnumerable <string> > Get() { var registerCommand = new RegisterCommand { NickName = "01" }; await _commandBus.Register <RegisterCommand>().Send(registerCommand); return(new string[] { "value12", "value22" }); }
public async Task <IEnumerable <string> > Get() { var command = new NewMenuCommand { Code = "xxx" }; Log.Information("Controller"); await _commandBus.Register <NewMenuCommand>() .Register <NewMenuCommand>() .Send(command); return(new string[] { "value1", "value2" }); }
public static void CommandHandlers(CommandBus bus, IRepository writeRepo) { var registrationHandlers = new UserRegistrationHandlers(writeRepo); bus.Register <Core.Registration.Register>(registrationHandlers.Handle); var chatMessageHandlers = new ChatMessageHandlers(writeRepo); bus.Register <EditChatMessage>(chatMessageHandlers.Handle); bus.Register <SubmitChatMessage>(chatMessageHandlers.Handle); var channelHandlers = new ChannelCommandHandlers(writeRepo); bus.Register <CreateChannel>(channelHandlers.Handle); bus.Register <JoinChannel>(channelHandlers.Handle); bus.Register <LeaveChannel>(channelHandlers.Handle); }