public void AddProductItem(ProductCode prodCode, ProductQuantity quantity) { if (prodCode == null) { throw new ArgumentNullException(nameof(prodCode)); } if (quantity == null) { throw new ArgumentNullException(nameof(quantity)); } // kontrola invariantu agregatu var item = TryGetInvoiceItem(prodCode); if (item != null) { throw new InvalidOperationException($"Invoice item already exists for product code {prodCode}"); } _items[prodCode] = new InvoiceItem(prodCode, quantity); }
public InvoiceItem(ProductCode productCode, ProductQuantity productQuantity) { ProductCode = productCode ?? throw new ArgumentNullException(nameof(productCode)); ProductQuantity = productQuantity ?? throw new ArgumentNullException(nameof(productQuantity)); }