Agathas.Storefront.Shopping.Model.Baskets.BasketItemFactory.create_item_for C# (CSharp) Method

create_item_for() public static method

public static create_item_for ( Agathas.Storefront.Shopping.Model.Baskets.ProductSnapshot product_snapshot ) : BasketItem
product_snapshot Agathas.Storefront.Shopping.Model.Baskets.ProductSnapshot
return BasketItem
        public static BasketItem create_item_for(ProductSnapshot product_snapshot)
        {
            return new BasketItem(product_snapshot, new NonNegativeQuantity(1));
        }

Usage Example

        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);
        }
BasketItemFactory