public void remove_product_with_id_of(ProductSnapshot product, IBasketPricingService basket_pricing_service)
        {
            if (basket_contains_an_item_for(product))
            {
                _items.Remove(get_item_for(product));

                recalculate_basket_totals(basket_pricing_service);
            }
        }
コード例 #2
0
ファイル: Basket.cs プロジェクト: elbandit/PPPDDD
        public void add(ProductSnapshot product_snapshot, IBasketPricingService basket_pricing_service)
        {
            // TODO: Check for null values and invalid data

            if (basket_contains_an_item_for(product_snapshot))
                get_item_for(product_snapshot).increase_item_quantity_by(new NonNegativeQuantity(1));
            else
                _items.Add(BasketItemFactory.create_item_for(product_snapshot));

            recalculate_basket_totals(basket_pricing_service);
        }
        public void add(ProductSnapshot product_snapshot, IBasketPricingService basket_pricing_service)
        {
            // TODO: Check for null values and invalid data

            if (basket_contains_an_item_for(product_snapshot))
            {
                get_item_for(product_snapshot).increase_item_quantity_by(new NonNegativeQuantity(1));
            }
            else
            {
                _items.Add(BasketItemFactory.create_item_for(product_snapshot));
            }

            recalculate_basket_totals(basket_pricing_service);
        }
コード例 #4
0
ファイル: Basket.cs プロジェクト: elbandit/PPPDDD
        public void change_quantity_of_product(NonNegativeQuantity quantity, ProductSnapshot product_snapshot, IBasketPricingService basket_pricing_service)
        {
            // TODO: Check for null values and invalid data

            if (basket_contains_an_item_for(product_snapshot))
            {
                if (quantity.is_zero())
                {
                    remove_product_with_id_of(product_snapshot, basket_pricing_service);
                }
                else
                    get_item_for(product_snapshot).change_item_quantity_to(quantity);

                recalculate_basket_totals(basket_pricing_service);
            }
        }
        public void change_quantity_of_product(NonNegativeQuantity quantity, ProductSnapshot product_snapshot, IBasketPricingService basket_pricing_service)
        {
            // TODO: Check for null values and invalid data

            if (basket_contains_an_item_for(product_snapshot))
            {
                if (quantity.is_zero())
                {
                    remove_product_with_id_of(product_snapshot, basket_pricing_service);
                }
                else
                {
                    get_item_for(product_snapshot).change_item_quantity_to(quantity);
                }

                recalculate_basket_totals(basket_pricing_service);
            }
        }
コード例 #6
0
ファイル: BasketItemFactory.cs プロジェクト: elbandit/PPPDDD
 public static BasketItem create_item_for(ProductSnapshot product_snapshot)
 {
     return new BasketItem(product_snapshot, new NonNegativeQuantity(1));
 }
コード例 #7
0
ファイル: Basket.cs プロジェクト: elbandit/PPPDDD
 private BasketItem get_item_for(ProductSnapshot product_snapshot)
 {
     return _items.Where(i => i.contains(product_snapshot)).FirstOrDefault();
 }
コード例 #8
0
ファイル: Basket.cs プロジェクト: elbandit/PPPDDD
 private bool basket_contains_an_item_for(ProductSnapshot product_snapshot)
 {
     return _items.Any(i => i.contains(product_snapshot));
 }
コード例 #9
0
ファイル: Basket.cs プロジェクト: elbandit/PPPDDD
        public void remove_product_with_id_of(ProductSnapshot product, IBasketPricingService basket_pricing_service)
        {
            if (basket_contains_an_item_for(product))
            {
                _items.Remove(get_item_for(product));

                recalculate_basket_totals(basket_pricing_service);
            }
        }
コード例 #10
0
 public bool contains(ProductSnapshot product_snapshot)
 {
     return(_product_snapshot == product_snapshot);
 }
コード例 #11
0
 public BasketItem(ProductSnapshot product_snapshot, NonNegativeQuantity quantity)
 {
     _id = Guid.NewGuid();
     _product_snapshot = product_snapshot;
     _quantity         = quantity;
 }
 private bool basket_contains_an_item_for(ProductSnapshot product_snapshot)
 {
     return(_items.Any(i => i.contains(product_snapshot)));
 }
 private BasketItem get_item_for(ProductSnapshot product_snapshot)
 {
     return(_items.Where(i => i.contains(product_snapshot)).FirstOrDefault());
 }
コード例 #14
0
ファイル: BasketItem.cs プロジェクト: elbandit/PPPDDD
 public bool contains(ProductSnapshot product_snapshot)
 {
     return _product_snapshot == product_snapshot;
 }
コード例 #15
0
ファイル: BasketItem.cs プロジェクト: elbandit/PPPDDD
 public BasketItem(ProductSnapshot product_snapshot, NonNegativeQuantity quantity)
 {
     _id = Guid.NewGuid();
     _product_snapshot = product_snapshot;
     _quantity = quantity;
 }
コード例 #16
0
 public static BasketItem create_item_for(ProductSnapshot product_snapshot)
 {
     return(new BasketItem(product_snapshot, new NonNegativeQuantity(1)));
 }