Example #1
0
        public Product Update(
            string name,
            ProductBarcode barcode,
            MoneyValue price,
            ProductCategory category
            )
        {
            if (string.IsNullOrEmpty(name))
            {
                name = Name;
            }

            if (barcode is null)
            {
                barcode = new ProductBarcode(Barcode.Value);
            }

            if (price is null)
            {
                price = new MoneyValue(Price.Value);
            }

            var newProduct = new Product(
                name,
                barcode,
                price,
                category
                );

            LatestVersion            = false;
            newProduct.lastVersion   = this;
            newProduct.LatestVersion = true;

            return(newProduct);
        }
Example #2
0
 public Product(
     string name,
     ProductBarcode barcode,
     MoneyValue price,
     ProductCategory category
     )
 {
     Id            = new ProductId(Guid.NewGuid());
     Name          = name;
     Barcode       = barcode;
     Price         = price;
     this.category = category;
     lastVersion   = null;
     LatestVersion = true;
 }