Example #1
0
        private async Task TakeProductCommand(BehaviorContext <OrderState, OrderAcceptedEvent> context)
        {
            var uri          = QueueNames.GetMessageUri(nameof(TakeProductMessage));
            var sendEndpoint = await context.GetSendEndpoint(uri);

            await sendEndpoint.Send <TakeProductMessage>(new
            {
                CorrelationId = context.Data.CorrelationId,
                OrderId       = context.Data.OrderId
            });
        }
Example #2
0
        public async Task Execute(BehaviorContext <OrderState, IOrderSubmittedEvent> context,
                                  Behavior <OrderState, IOrderSubmittedEvent> next)
        {
            var sendEndpoint = await context.GetSendEndpoint(QueueNames.GetMessageUri(nameof(IFulfillOrder)));

            _logger.LogInformation($"Order Transaction activity for sendEndpoint {sendEndpoint} will be called");
            await sendEndpoint.Send <IFulfillOrder>(new
            {
                CorrelationId = context.Data.CorrelationId,
                OrderId       = context.Data.OrderId,
            });
        }
        public async Task Execute(BehaviorContext <OrderTransactionState, OrderTransactionSubmittedEvent> context, Behavior <OrderTransactionState, OrderTransactionSubmittedEvent> next)
        {
            var sendEndpoint = await context.GetSendEndpoint(QueueNames.GetMessageUri(nameof(FullfillOrderMessage)));

            logger.LogInformation($"Order Transaction activity for sendEndpoint {sendEndpoint} will be called");
            await sendEndpoint.Send <FullfillOrderMessage>(new
            {
                OrderId    = context.Data.OrderId,
                Credit     = context.Data.Credit,
                CustomerId = context.Data.CustomerId
            });
        }
Example #4
0
        private async Task WithdrawCustomerCreditCommand(BehaviorContext <OrderState, OrderSubmittedEvent> context)
        {
            var uri          = QueueNames.GetMessageUri(nameof(WithdrawCustomerCreditMessage));
            var sendEndpoint = await context.GetSendEndpoint(uri);

            await sendEndpoint.Send <WithdrawCustomerCreditMessage>(new
            {
                CorrelationId = context.Data.CorrelationId,
                Credit        = context.Data.Credit,
                CustomerId    = context.Data.CustomerId,
                OrderId       = context.Data.OrderId
            });
        }
        public async Task Execute(BehaviorContext <OrderState, IOrderSubmitted> context, Behavior <OrderState, IOrderSubmitted> next)
        {
            var uri = QueueNames.GetMessageUri(nameof(IAssetCanBeProtectedEvent));

            var sendEndpoint = await context.GetSendEndpoint(uri);

            await sendEndpoint.Send <IAssetCanBeProtectedEvent>(new
            {
                OrderId = context.Data.OrderId
            });

            await next.Execute(context).ConfigureAwait(false);
        }
        public async Task <CompensationResult> Compensate(CompensateContext <TakeProductLog> context)
        {
            logger.LogInformation($"Compensate Take Product Courier called for order {context.Log.OrderId}");
            var uri          = QueueNames.GetMessageUri(nameof(ReturnProductTransactionMessage));
            var sendEndpoint = await context.GetSendEndpoint(uri);

            await sendEndpoint.Send <ReturnProductTransactionMessage>(new
            {
                ProductBaskets = context.Log.Baskets
            });

            return(context.Compensated());
        }
Example #7
0
        public async Task Execute(BehaviorContext <OrderState, IAssetCanBeProtectedEvent> context, Behavior <OrderState, IAssetCanBeProtectedEvent> next)
        {
            var uri = QueueNames.GetMessageUri(nameof(ITryBlockBalanceCommand));

            var sendEndpoint = await context.GetSendEndpoint(uri);

            await sendEndpoint.Send <ITryBlockBalanceCommand>(new
            {
                OrderId = context.Data.OrderId,
                Amount  = 100m
            });

            await next.Execute(context).ConfigureAwait(false);
        }
        public async Task <ExecutionResult> Execute(ExecuteContext <TakeProductArgument> context)
        {
            logger.LogInformation($"Take Product Courier called for order {context.Arguments.OrderId}");
            var uri          = QueueNames.GetMessageUri(nameof(TakeProductTransactionMessage));
            var sendEndpoint = await context.GetSendEndpoint(uri);

            //await sendEndpoint.Send<TakeProductTransactionMessage>(new
            //{
            //    ProductBaskets = context.Arguments.Baskets
            //});
            await requestClient.GetResponse <IRequestResult>(new { ProductBaskets = context.Arguments.Baskets });

            return(context.Completed(new { Baskets = context.Arguments.Baskets, OrderId = context.Arguments.OrderId }));
        }
        public async Task <CompensationResult> Compensate(CompensateContext <PaymentLog> context)
        {
            logger.LogInformation($"Payment copmensated Courier called for customer {context.Log.CustomerId}");
            var uri          = QueueNames.GetMessageUri(nameof(ReturnCustomerCreditMessage));
            var sendEndpoint = await context.GetSendEndpoint(uri);

            await sendEndpoint.Send <ReturnCustomerCreditMessage>(new
            {
                Credit     = context.Log.Credit,
                CustomerId = context.Log.CustomerId
            });

            return(context.Compensated());
        }
        public async Task <ExecutionResult> Execute(ExecuteContext <PaymentArgument> context)
        {
            logger.LogInformation($"Payment Courier called for order {context.Arguments.OrderId}");
            var uri          = QueueNames.GetMessageUri(nameof(WithdrawCustomerCreditMessage));
            var sendEndpoint = await context.GetSendEndpoint(uri);

            await sendEndpoint.Send <WithdrawCustomerCreditMessage>(new
            {
                Credit     = context.Arguments.Credit,
                CustomerId = context.Arguments.CustomerId,
                OrderId    = context.Arguments.OrderId
            });

            return(context.Completed(new { CustomerId = context.Arguments.CustomerId, Credit = context.Arguments.Credit }));
        }