Exemplo n.º 1
0
        public void Post([FromBody] JObject value)
        {
            // example of handling an event

            var orderEvent = value.ToObject <OrderEvent>();

            var orderInfo = JsonConvert.DeserializeObject <OrderEventData>(orderEvent.Body);

            if (string.Equals(orderEvent.EventType, "OrderCreated", StringComparison.OrdinalIgnoreCase))
            {
                var email = new Email
                {
                    Body = $"New order created with OrderID {orderInfo.OrderId}!",
                };
                _emailRepository.Create(email);
            }

            _orderRepository.AcknowledgeEvent(orderEvent.EventId);
        }