public async Task Run([EventGridTrigger] EventGridEvent eventGridEvent, ILogger log, CancellationToken cancellationToken) { var payload = eventGridEvent.GetPayload <OrderCreatedPayload>(); var request = new GetOrderByIdRequest { OrderId = payload.OrderId }; GetOrderByIdResponse response = await _mediator.Send(request, cancellationToken); // Handle the event log.LogInformation($"Handled OnOrderCreated for OrderId {response.Order.OrderId}"); }
public Task <Result <GetOrderByIdResponse> > ExecuteAsync(GetOrderByIdRequest request) { var response = new GetOrderByIdResponse { OrderId = request.OrderId, Products = Enumerable.Range(1, request.OrderId.Length).Select(x => new Product { ProductId = $"PROD_{x}", Name = $"Product name {x}", Description = $"Product description {x}" }).ToList() }; return(Task.FromResult(Result <GetOrderByIdResponse> .Success(response))); }
public async Task <ActionResult <Order> > Get(long orderId, CancellationToken cancellationToken) { if (orderId < 1) { return(BadRequest()); } var request = new GetOrderByIdRequest { OrderId = orderId }; GetOrderByIdResponse response = await _mediator.Send(request, cancellationToken); return(new OkObjectResult(response.Order)); }