예제 #1
0
        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}");
        }
예제 #2
0
        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)));
        }
예제 #3
0
        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));
        }