using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;
namespace Mall.Cart
{
    public partial class Cart : System.Web.UI.Page
    {
        public List<MODEL.MModelProductListHelper> plists = new List<MODEL.MModelProductListHelper>();
        public string[] plist;
        protected void Page_Load(object sender, EventArgs e)
        {
            string buylist = string.Empty;
            buylist = Request.Cookies["cart"] == null ? "" : Request.Cookies["cart"].Value.ToString();
            buylist = Server.UrlDecode(buylist);
            plist = buylist.Split(new char[] { ',' });
            if (plist.Length == 0)
            {

                plist[0] = buylist;
            }
            foreach (string s in plist)
            {
                if (s.IndexOf("{$s$}") < 0)
                {

                    continue;
                }
                MODEL.MModelProductListHelper model = new MODEL.MModelProductListHelper();
                string[] pInfos = s.Split(new string[] { "{$s$}" }, StringSplitOptions.None);
                string priductid = pInfos[0];
                string[] tempstrs = pInfos[1].Split(new string[] { "{$yc$}" }, StringSplitOptions.None);
                string Pcount = tempstrs[0];
                tempstrs = tempstrs[1].Replace(" ", "").Split(new string[] { "\"\"" }, StringSplitOptions.None);
                string yanse = tempstrs[0].Replace("\"", "");
                string cima = tempstrs[1].Replace("\"", "");
                BLL.Models.ProductModels models = new BLL.Models.ProductModels();
                MODEL.MProduct model_product = new MODEL.MProduct();
                model.Priductid = Convert.ToInt32(priductid);
                model.CountBuy = Convert.ToInt32(Pcount);
                model.Cima = cima;
                model.Yanse = yanse;
                model_product = models.GetProductById(model.Priductid.ToString());
                if (model_product.Id == null)
                {

                    continue;
                }
                model.Model_product = model_product;
                plists.Add(model);
            }
           // ViewData["plist"] = plists;

            //return RedirectToAction("cart", "cart");
        }
    }
}