Ejemplo n.º 1
0
        public IActionResult Post(NewOrderRequest request)
        {
            var newOrder = new Order
            {
                Id    = Orders.Select(x => x.Id).DefaultIfEmpty().Max() + 1,
                Email = request.Email
            };

            Orders.Add(newOrder);
            var payload = JsonSerializer.Serialize(newOrder);

            _logger.LogInformation($"New order created: {payload}");

            _rabbitMqClient.Publish("ordering", "order.created", payload);

            return(CreatedAtAction(nameof(GetById), new { id = newOrder.Id }, newOrder));
        }