public static void Clear(List <cart_keys> ls) { if (ls == null) { return; } List <cart_keys> cart = ShopCart.GetCart(); if (cart == null) { return; } using (List <cart_keys> .Enumerator enumerator = ls.GetEnumerator()) { while (enumerator.MoveNext()) { cart_keys modelt = enumerator.Current; cart_keys cartKeys = cart.Find((Predicate <cart_keys>)(p => p.article_id == modelt.article_id)); if (cartKeys != null) { cart.Remove(cartKeys); } } } ShopCart.AddCookies(JsonHelper.ObjectToJSON((object)cart)); }
public static bool Add(int article_id, int goods_id, int quantity) { List <cart_keys> cartKeysList = ShopCart.GetCart(); if (cartKeysList != null) { cart_keys cartKeys = cartKeysList.Find((Predicate <cart_keys>)(p => p.article_id == article_id)); if (cartKeys != null) { int index = cartKeysList.FindIndex((Predicate <cart_keys>)(p => p.article_id == article_id)); cartKeys.quantity += quantity; cartKeysList[index] = cartKeys; ShopCart.AddCookies(JsonHelper.ObjectToJSON((object)cartKeysList)); return(true); } } else { cartKeysList = new List <cart_keys>(); } cartKeysList.Add(new cart_keys() { article_id = article_id, quantity = quantity }); ShopCart.AddCookies(JsonHelper.ObjectToJSON((object)cartKeysList)); return(true); }
public static void Clear(int article_id, int goods_id) { if (article_id > 0) { List <cart_keys> cart = ShopCart.GetCart(); if (cart == null) { return; } cart_keys cartKeys = cart.Find((Predicate <cart_keys>)(p => p.article_id == article_id)); if (cartKeys != null) { cart.Remove(cartKeys); ShopCart.AddCookies(JsonHelper.ObjectToJSON((object)cart)); } } }
public static cart_keys Update(int article_id, int quantity) { if (quantity < 1) { return((cart_keys)null); } List <cart_keys> cart = ShopCart.GetCart(); if (cart != null) { cart_keys cartKeys = cart.Find((Predicate <cart_keys>)(p => p.article_id == article_id)); if (cartKeys != null) { int index = cart.FindIndex((Predicate <cart_keys>)(p => p.article_id == article_id)); cartKeys.quantity = quantity; cart[index] = cartKeys; ShopCart.AddCookies(JsonHelper.ObjectToJSON((object)cart)); return(cartKeys); } } return((cart_keys)null); }