예제 #1
0
 public IActionResult Post(
     [FromBody] RegisterUserDto dto,
     [FromServices] IRegisterUserCommand command)
 {
     _executor.ExecuteCommand(command, dto);
     return(StatusCode(StatusCodes.Status201Created));
 }
예제 #2
0
 public UsersController(
     IRegisterUserCommand registerUserCommand,
     IInactivateUserCommand inactivateUserCommand,
     IUSerProfileQuery userProfileQuery)
 {
     _registerUsersCommand  = registerUserCommand;
     _inactivateUserCommand = inactivateUserCommand;
     _userProfileQuery      = userProfileQuery;
 }
예제 #3
0
 public UsersController(
     IGetUsersCommand getUsersCommand,
     IGetUserCommand getUserCommand,
     IRegisterUserCommand registerUserCommand)
 {
     _getUsersCommand     = getUsersCommand;
     _getUserCommand      = getUserCommand;
     _registerUserCommand = registerUserCommand;
 }
예제 #4
0
        private void Consume(IRegisterUserCommand command)
        {
            // Store order registration and get id
            int id = 12;

            Console.WriteLine($"Order with id {id} registered");
            Console.WriteLine("Publishing order registered event");

            //notify subscribers that a order is registered
            var orderRegisteredEvent = new UserRegisteredEvent(command, id);

            //publish event
            _rabbitMqManager.SendUserRegisteredEvent(orderRegisteredEvent);
        }
예제 #5
0
        public void SendRegisterUserCommand(IRegisterUserCommand command)
        {
            // Exchange creation (do nothing if already exists)

            channel.ExchangeDeclare(
                exchange: Constants.RegisterUserExchange,
                type: ExchangeType.Direct);

            // Queue creation (do nothing if already exists)


            // durable : queue exists only in memory only and it will not persist to disc
            // exclusive : created queue exclusive for this connection
            // autoDelete : automatic delete of queue when the last consumer closes its channel
            // arguments: advance queue creation (out of scope for now)

            channel.QueueDeclare(
                queue: Constants.RegisterUserQueue, durable: false,
                exclusive: false, autoDelete: false, arguments: null);

            // Bind between exchange-queue creatation (do nothing if already exists)

            channel.QueueBind(
                queue: Constants.RegisterUserQueue,
                exchange: Constants.RegisterUserExchange,
                routingKey: "");

            var serializedCommand = JsonConvert.SerializeObject(command);

            var messageProperties = channel.CreateBasicProperties();

            messageProperties.ContentType = Constants.JsonMimeType;

            channel.BasicPublish(
                exchange: Constants.RegisterUserExchange,
                basicProperties: messageProperties,
                routingKey: "",
                body: Encoding.UTF8.GetBytes(serializedCommand));
        }
예제 #6
0
 public void Post([FromBody] RegisterUserDto dto, [FromServices] IRegisterUserCommand command)
 {
     executor.ExecuteCommand(command, dto);
 }
예제 #7
0
 public ViewEventModel(IEventQuery eventQuery, IRegisterUserCommand registerUser)
 {
     _eventQuery   = eventQuery;
     _registerUser = registerUser;
 }
예제 #8
0
 public UserRegisteredEvent(IRegisterUserCommand command, int userId)
 {
     this.command = command;
     this.userId  = userId;
 }
 public UserRegisteredEvent(IRegisterUserCommand command, int userId)
 {
     _command = command;
     _userId  = userId;
 }
 public void Post([FromBody] RegisterUserDto request, [FromServices] IRegisterUserCommand command)
 {
     _executor.ExecuteCommand(command, request);
 }