示例#1
0
 public InMemoryData()
 {
     items = new List <Item>()
     {
         new Item {
             Sku = 'A', Quantity = 0, Price = 50
         },
         new Item {
             Sku = 'B', Quantity = 0, Price = 30
         },
         new Item {
             Sku = 'C', Quantity = 0, Price = 20
         },
         new Item {
             Sku = 'D', Quantity = 0, Price = 15
         }
     };
     cart = new Cart();
     foreach (var item in items)
     {
         cart.AddCartItems(item);
     }
     promotions = new List <Promotions>()
     {
         new Promotions {
             Id = 1, Type = "Single", Details = "3 of A's for 130", Quantity = 3, Price = 130, PrimarySku = 'A'
         },
         new Promotions {
             Id = 2, Type = "Single", Details = "2 of B's for 45", Quantity = 2, Price = 45, PrimarySku = 'B'
         },
         new Promotions {
             Id = 3, Type = "Multiple", Details = "C & D For 30", Quantity = 1, Price = 30, PrimarySku = 'C', SecondarySku = 'D'
         },
     };
 }
示例#2
0
        public void AddItemsToCart(char id, int qty)
        {
            var item = cart.GetCartItemById(id);

            if (item != null)
            {
                cart.RemoveCartItem(id);
                item.Quantity = qty;
                cart.AddCartItems(item);
            }
        }