use of pl.com.bottega.erp.sales.domain.Product in project ddd-cqrs-sample by BottegaIT.
the class AddProductToOrderCommandHandler method handle.
@Override
public Void handle(AddProductToOrderCommand command) {
Product product = productRepository.load(command.getProductId());
Order order = orderRepository.load(command.getOrderId());
order.addProduct(product, command.getQuantity());
orderRepository.save(order);
return null;
}
use of pl.com.bottega.erp.sales.domain.Product in project ddd-cqrs-sample by BottegaIT.
the class PurchaseApplicationService method addProductToOrder.
/**
* Sample call of the domain logic<br>
* Sample publishing Application (not Domain) Event
*
* @param productId
* @param orderId
* @param quantity
*/
public void addProductToOrder(Long productId, Long orderId, int quantity) {
Order order = orderRepository.load(orderId);
Product product = productRepository.load(productId);
// Domain logic
order.addProduct(product, quantity);
orderRepository.save(order);
// if we want to Spy Clients:)
eventPublisher.publish(new ProductAddedToOrderEvent(product.getEntityId(), systemUser.getUserId(), quantity));
}
Aggregations