예제 #1
0
        private bool ValidProductItem(Products.ProductItem productItem)
        {
            if (productItem.IsValid())
            {
                return(true);
            }

            NotifyErrorValidations(productItem.ValidationResult);
            return(false);
        }
예제 #2
0
        public void Handle(CreateProductItemCommand message)
        {
            var productItem = new Products.ProductItem(message.ProductId, message.ProductItemId, message.Units);

            if (!ValidProductItem(productItem))
            {
                return;
            }

            // Criar demais validações de negócio

            _productRepository.AddProductItem(productItem);

            if (Commit())
            {
                _bus.RaiseEvent(new CreatedProductItemEvent(productItem.Id, productItem.ProductId, productItem.ProductItemId, productItem.Units));
            }
        }