示例#1
0
        public void RemoveItem(string productId, string unitId)
        {
            var vanItem = ShoppingVanItems.FirstOrDefault(x => x.ProductId == productId);

            if (vanItem == null)
            {
                throw new ShoppingVanItemNotFound(productId, unitId);
            }

            TotalItemsCount -= 1;
            var unit = vanItem.DecreaseUnit(unitId);

            TotalPrice -= unit.SellingPrice;

            AddDomainEvent(new ShoppingVanUpdated(this));
        }
示例#2
0
        public void AddItem(string productId, string productName, string photoUrl, List <Unit> units, string unitId)
        {
            // Check if the product exist in the shopping van items or not if not will will add it with the required amount
            var vanItem = ShoppingVanItems.FirstOrDefault(x => x.ProductId == productId);

            if (vanItem == null)
            {
                vanItem = new VanItem(Id.ToString(), productId, productName, photoUrl, units);
                ShoppingVanItems.Add(vanItem);
            }

            var unit = vanItem.IncreaseUnit(unitId);

            TotalItemsCount += 1;
            TotalPrice      += unit.SellingPrice;

            AddDomainEvent(new ShoppingVanUpdated(this));
        }