public async Task Handle(CancelCarRequest message, IMessageHandlerContext context)
 {
     Log.Info($"Car for Trip Id {message.TripId} is canceled");
     var result = new RentCarResponse {
         TripId = message.TripId, IsBooked = false
     };
     await context.Publish(result);
 }
        public async Task Handle(RentCarRequest message, IMessageHandlerContext context)
        {
            var result = new RentCarResponse {
                TripId = message.TripId
            };

            try
            {
                Log.Info($"Car for Trip Id {message.TripId} is rent");
                result.IsBooked = true;
            }
            catch (Exception e)
            {
                Log.Info($"Booking car for Trip Id {message.TripId} is failed", e);
                result.IsBooked = false;
            }

            await context.Publish(result);
        }
示例#3
0
        public async Task Handle(RentCarResponse message, IMessageHandlerContext context)
        {
            if (message.IsBooked)
            {
                Data.OrderStatuses[OrderType.Car] = OrderStatus.Confirmed;
                Log.Info($"Car is rented for Tour Id {message.TripId}");
                Log.Info("Sending purchase tickets request...");
                var command = new TicketsPurchaseRequest {
                    TripId = message.TripId
                };
                await context.Send(command);

                Data.OrderStatuses[OrderType.FlichtTickets] = OrderStatus.OrderRequestIsSent;
            }
            else
            {
                Log.Info($"Car is canceled for Tour Id {message.TripId}");
                Data.OrderStatuses[OrderType.Car] = OrderStatus.Canceled;
                await CancelSaga(context);
            }

            await TryCompleteSaga();
        }