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);
            }
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 4
0
        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);
            }
        }
Exemplo n.º 6
0
 public static BasketItem create_item_for(ProductSnapshot product_snapshot)
 {
     return new BasketItem(product_snapshot, new NonNegativeQuantity(1));
 }
Exemplo n.º 7
0
 private BasketItem get_item_for(ProductSnapshot product_snapshot)
 {
     return _items.Where(i => i.contains(product_snapshot)).FirstOrDefault();
 }
Exemplo n.º 8
0
 private bool basket_contains_an_item_for(ProductSnapshot product_snapshot)
 {
     return _items.Any(i => i.contains(product_snapshot));
 }
Exemplo n.º 9
0
        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);
            }
        }
 public bool contains(ProductSnapshot product_snapshot)
 {
     return(_product_snapshot == product_snapshot);
 }
 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());
 }
Exemplo n.º 14
0
 public bool contains(ProductSnapshot product_snapshot)
 {
     return _product_snapshot == product_snapshot;
 }
Exemplo n.º 15
0
 public BasketItem(ProductSnapshot product_snapshot, NonNegativeQuantity quantity)
 {
     _id = Guid.NewGuid();
     _product_snapshot = product_snapshot;
     _quantity = quantity;
 }
Exemplo n.º 16
0
 public static BasketItem create_item_for(ProductSnapshot product_snapshot)
 {
     return(new BasketItem(product_snapshot, new NonNegativeQuantity(1)));
 }