示例#1
0
        protected List <cart_items> get_cart_list()
        {
            int group_id = 0;

            Rain.Model.users userInfo = this.GetUserInfo();
            if (userInfo != null)
            {
                group_id = userInfo.group_id;
            }
            return(ShopCart.GetList(group_id) ?? new List <cart_items>());
        }
示例#2
0
文件: ShoppingCart.cs 项目: Hcq/Rain
        private static List <cart_keys> GetCart()
        {
            List <cart_keys> cartKeysList = new List <cart_keys>();
            string           cookies      = ShopCart.GetCookies();

            if (!string.IsNullOrEmpty(cookies))
            {
                return(JsonHelper.JSONToObject <List <cart_keys> >(cookies));
            }
            return((List <cart_keys>)null);
        }
示例#3
0
文件: ShoppingCart.cs 项目: Hcq/Rain
 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));
         }
     }
 }
示例#4
0
文件: ShoppingCart.cs 项目: Hcq/Rain
        public static int GetQuantityCount()
        {
            string cookies = ShopCart.GetCookies();
            int    num     = 0;

            if (!string.IsNullOrEmpty(cookies))
            {
                List <cart_keys> cartKeysList = JsonHelper.JSONToObject <List <cart_keys> >(cookies);
                if (cartKeysList != null)
                {
                    foreach (cart_keys cartKeys in cartKeysList)
                    {
                        num += cartKeys.quantity;
                    }
                }
            }
            return(num);
        }
示例#5
0
文件: ShoppingCart.cs 项目: Hcq/Rain
        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);
        }
示例#6
0
 protected int get_cart_quantity()
 {
     return(ShopCart.GetQuantityCount());
 }
示例#7
0
文件: ShoppingCart.cs 项目: Hcq/Rain
 public static cart_total GetTotal(int group_id)
 {
     return(ShopCart.GetTotal(ShopCart.GetList(group_id)));
 }
示例#8
0
文件: ShoppingCart.cs 项目: Hcq/Rain
 public static List <cart_items> GetList(int group_id)
 {
     return(ShopCart.ToList(ShopCart.GetCart(), group_id));
 }