public void AddToCart(long item_id, string item_name, string item_description, string item_url, decimal item_price, string item_unit, int item_discount, int product_count = 1) { IcbcodeCartItem cart_item = Items.Find(delegate(IcbcodeCartItem item) { return(item.item_id == item_id); }); if (cart_item == null) { Items.Add(new IcbcodeCartItem() { item_id = item_id, item_name = item_name, item_description = item_description, item_url = item_url, item_price = item_price, item_unit = item_unit, item_count = product_count, item_discount = item_discount }); } else { cart_item.item_count = cart_item.item_count + 1; } }
public void RemoveFromCart(long item_id, int item_count) { IcbcodeCartItem cart_item = Items.Find(delegate(IcbcodeCartItem item) { return(item.item_id == item_id); }); if (cart_item != null) { if (cart_item.item_count > 1 && (cart_item.item_count - item_count) > 0) { cart_item.item_count = cart_item.item_count - 1; } else { Items.Remove(cart_item); } } }