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); }
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); }
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 }); }
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); }
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)); }
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)); }