예제 #1
0
        public async Task HandleAsync(IMessageContext <InventoryCheckCompleted> context, CancellationToken cancellationToken = default)
        {
            _logger.LogInformation($"inventory check for order '{context.Message.OrderId}' completed!");

            this.State.InventoryCheckCompleted = true;

            if (CheckCanShipOrder(cancellationToken))
            {
                var message = ProcessShipping.New(this.State.OrderId);
                this.Publish(message);
            }
        }
예제 #2
0
        private async Task CheckStateAsync(CancellationToken cancellationToken = default)
        {
            var checksFulfilled = this.State.CreditCheckCompleted &&
                                  this.State.InventoryCheckCompleted;

            if (!checksFulfilled)
            {
                return;
            }

            var message = ProcessShipping.New(this.State.OrderId);

            await this.Bus.PublishAsync(message, cancellationToken);
        }