public async Task Handle(BookingStartedIntegrationEvent message, IMessageHandlerContext context) { Data.UserId = message.UserId; var bookingStockItem = new BookingStockItem(message.ProductId, message.Units); var ev = new BookingStatusChangedToCheckIntegrationEvent(message.BookingId, bookingStockItem); await context.Publish(ev); }
public async Task <IActionResult> Checkout([FromBody] BookingCheckout bookingCheckout) { var userId = _identityService.GetUserIdentity(); //to do: check unique request id var booking = new Booking(bookingCheckout.ProductId, bookingCheckout.ProductName, bookingCheckout.UnitPrice, bookingCheckout.Quantity, userId); _bookingRepository.Add(booking); await _bookingRepository.SaveChangesAsync(); var eventMessage = new BookingStartedIntegrationEvent(userId, booking.Id, bookingCheckout.ProductId, bookingCheckout.Quantity); await _endpoint.Publish(eventMessage); return(Accepted()); }