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
{
    public partial class Views : System.Web.UI.Page
    {
       public MODEL.MProduct mpurduct = new MODEL.MProduct();
       public string str_html_left_allclass = string.Empty;
       public string str_html_left_top_views = string.Empty;
       public string str_html_left_class_views = string.Empty;
       public string str_html_down_product_list = string.Empty;
       public string str_html_left_his_views = string.Empty;
        protected void Page_Load(object sender, EventArgs e)
        {
            string id = string.Empty;
            if (Request["Productid"] != null)
            {

                id = Request["productid"].ToString();
            }
            string lastview = Request.Cookies["lastview"] == null ? "" : Request.Cookies["lastview"].Value.ToString();

            BLL.Models.ProductModels msproduct = new BLL.Models.ProductModels();
            BLL.Models.MClassModels model_class = new BLL.Models.MClassModels();
             mpurduct = msproduct.GetProductById(id);
             str_html_left_allclass = model_class.GetListClassAll();
             str_html_left_top_views = model_class.GetViewsPathById(mpurduct.Classid.ToString());
             str_html_left_class_views = model_class.GetViewsLeft(mpurduct.Classid.ToString());
             str_html_down_product_list = msproduct.GetProductListForViewDown(mpurduct.Classid.ToString());
             str_html_left_his_views = msproduct.GetProductHisLeft(7, lastview);
            StringBuilder str_lastview = new StringBuilder();
            str_lastview.Append(id);
            if (!string.IsNullOrEmpty(lastview) && lastview.IndexOf(",") > -1)
            {
                string[] listviews = lastview.Split(new char[] { ',' });
                //listviews.Reverse();
                int i = 0;
                foreach (string s in listviews)
                {
                    if (i > 100)
                    {
                        break;
                    }
                    str_lastview.Append(",");
                    str_lastview.Append(s);
                    i = i + 1;
                }

            }
            Response.Cookies["lastview"].Value = str_lastview.ToString();

        }
    }
}