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 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); }
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); } }
public static BasketItem create_item_for(ProductSnapshot product_snapshot) { return new BasketItem(product_snapshot, new NonNegativeQuantity(1)); }
private BasketItem get_item_for(ProductSnapshot product_snapshot) { return _items.Where(i => i.contains(product_snapshot)).FirstOrDefault(); }
private bool basket_contains_an_item_for(ProductSnapshot product_snapshot) { return _items.Any(i => i.contains(product_snapshot)); }
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()); }
public bool contains(ProductSnapshot product_snapshot) { return _product_snapshot == product_snapshot; }
public static BasketItem create_item_for(ProductSnapshot product_snapshot) { return(new BasketItem(product_snapshot, new NonNegativeQuantity(1))); }