コード例 #1
0
        private async Task MarkOrderAsCompleted(BehaviorContext <SagaInstance, OrderDelivered> context)
        {
            await context.Send(new Commands.CompleteOrder {
                OrderId = context.Data.ReferenceOrderId
            });

            _logger.LogInformation("Sending {command} for {order}", nameof(Commands.CompleteOrder), context.Data.ReferenceOrderId);
        }
コード例 #2
0
        private async Task MarkOrderAsFailed(BehaviorContext <SagaInstance, OrderReturned> context)
        {
            await context.Send(new Commands.FailOrder {
                OrderId = context.Data.ReferenceOrderId, Reason = "Returned, pizza cold"
            }).ConfigureAwait(false);

            _logger.LogInformation("Sending {command} for {order}", nameof(Commands.FailOrder), context.Data.ReferenceOrderId);
        }
コード例 #3
0
 static async Task InitiateProcessing(BehaviorContext <JobState, BatchJobReceived> context)
 {
     await context.Send <JobState, BatchJobReceived, ProcessBatchJob>(new
     {
         BatchJobId = context.Instance.CorrelationId,
         Timestamp  = DateTime.UtcNow,
         context.Instance.BatchId,
         context.Instance.OrderId,
         context.Instance.Action
     });
 }
コード例 #4
0
        private async Task CreateDelivery(BehaviorContext <SagaInstance, OrderPlaced> context)
        {
            await context.Send(new Delivery.Commands.PlaceOrder
            {
                ReferenceOrderId = context.Data.AggregateRootId,
                UserId           = context.Data.UserId,
                DeliveryDate     = context.Data.DeliveryInfo.DeliveryDate,
                PhoneNumber      = context.Data.DeliveryInfo.PhoneNumber,
                Address          = context.Data.DeliveryInfo.DeliveryAddress.Stringify()
            });

            _logger.LogInformation("Sending {command} for {order}", nameof(Commands.PlaceOrder), context.Data.AggregateRootId);
        }
コード例 #5
0
        public Task Execute(BehaviorContext <TInstance, TData> context, Behavior <TInstance, TData> next, Document document)
        {
            var notificationDto = new NotificationBuilder()
                                  .SetNotificationType(_notificationProvider.GetNotificationType())
                                  .SetTitle(_notificationProvider.GetTitle(document))
                                  .SetMessage(_notificationProvider.GetMessage(document))
                                  .Build()
                                  .ToDto();

            var sendNotificationCommand = new SendNotificationCommand(context.Instance.CorrelationId, notificationDto);

            context.Send(sendNotificationCommand);
            return(next.Execute(context));
        }
コード例 #6
0
        public override Task Execute(BehaviorContext <DeleteDocumentState, DocumentDeletedFromDbEvent> context, Behavior <DeleteDocumentState, DocumentDeletedFromDbEvent> next)
        {
            var emailProvider = _emailProviderFactory
                                .CreateDocumentDeletedSuccessFullyEmail(
                context.Data.User,
                context.Data.PayLoad.ToEmptyDocumentWithId());

            var emailDto = new EmailBuilder()
                           .SetTo(emailProvider.GetTo())
                           .SetCc(emailProvider.GetCc())
                           .SetSubject(emailProvider.GetSubject())
                           .SetBody(emailProvider.GetBody())
                           .Build()
                           .ToDto();

            var sendEmailCommand = new SendEmailCommand(context.Data.CorrelationId, emailDto);

            context.Send(sendEmailCommand).Wait();

            return(next.Execute(context));
        }