Exemplo n.º 1
0
        public void Handle(PotentialOrderPlaced evt)
        {
            var result = OrderFullFullfilment.CreateFrom(evt.Id, evt.ProductCode, evt.Quantity);

            _uow.Repository.Save(result.Entity);
            _uow.Bus.Publish(result.Event);
            _uow.Commit();
        }
        public IActionResult Post(FullfilOrderRequest request)
        {
            if (!OrderFullFullfilment.CanBeFullFilled(request.OrderId, request.ProductCode, request.Quantity))
            {
                return(BadRequest(OrderFullFullfilment.FullfillErrors(request.OrderId, request.ProductCode, request.Quantity)));
            }

            _service.FulfillOrder(request.OrderId, request.ProductCode, request.Quantity);

            return(Ok());
        }