/// <summary>
 /// 商品品牌信息
 /// </summary>
 /// <returns>
 /// The <see cref="ActionResult"/>.
 /// </returns>
 public ActionResult BrandInfo()
 {
     if (!string.IsNullOrEmpty(Request.QueryString["brandId"]))
     {
         int brandId = 2;
         int.TryParse(Request.QueryString["brandId"], out brandId);
         ViewBag.brandId = brandId.ToString();
         var productParent = new ProductBrandService().QueryById(brandId);
         if (productParent != null)
         {
             ViewBag.CategoryId = productParent.ProductCategoryID.ToString();
         }
         var brandInfo = new BrandInformationService().QueryByBrandID(brandId);
         if (brandInfo != null)
         {
             return this.View(brandInfo);
         }
     }
     Response.StatusCode = 404;
     return this.Content(Utils.ReadFile("Error/404.htm"));
 }
        /// <summary>
        /// 获取图片类别数据
        /// </summary>
        /// <param name="typeID">
        /// 类型编号(0:商品类别,1:商品品牌)
        /// </param>
        /// <param name="parent">
        /// 父级对象
        /// </param>
        /// <returns>
        /// 图片类别列表
        /// </returns>
        public List<PictureCategory> GetPictureCategories(int typeID, PictureCategory parent)
        {
            var pictureCategories = new List<PictureCategory>();

            this.productBrandService = new ProductBrandService();
            this.productCategoryService = new ProductCategoryService();

            object list;
            if (typeID == 0)
            {
                if (parent == null)
                {
                    list = this.productCategoryService.QueryCategoryByParentID(0);

                    var categories = list as List<Product_Category>;
                    if (categories != null)
                    {
                        foreach (var category in categories)
                        {
                            pictureCategories.Add(
                                new PictureCategory
                                {
                                    ID = category.ID,
                                    Text = category.CategoryName,
                                    Url = string.Empty,
                                    Level = 1
                                });
                        }
                    }
                }
                else
                {
                    list = this.productCategoryService.QueryCategoryByParentID(parent.ID);

                    var categories = list as List<Product_Category>;
                    if (categories != null)
                    {
                        foreach (var category in categories)
                        {
                            pictureCategories.Add(
                                new PictureCategory
                                {
                                    ID = category.ID,
                                    Text = category.CategoryName,
                                    Url = string.Empty,
                                    Level = 2
                                });
                        }
                    }
                }
            }

            if (typeID == 1 && parent != null)
            {
                if (parent.Level == 2)
                {
                    list = this.productBrandService.QueryProductBrandByCategoryID(parent.ID, 0);
                    var brands = list as List<Product_Brand>;
                    if (brands != null)
                    {
                        foreach (var brand in brands)
                        {
                            pictureCategories.Add(
                                new PictureCategory
                                {
                                    ID = brand.ID,
                                    Text = brand.BrandName,
                                    Url = string.Empty,
                                    Level = 3
                                });
                        }
                    }
                }

                if (parent.Level == 3)
                {
                    list = this.productBrandService.QueryProductBrandByParentID(parent.ID);
                    var brands = list as List<Product_Brand>;
                    if (brands != null)
                    {
                        foreach (var brand in brands)
                        {
                            pictureCategories.Add(
                                new PictureCategory
                                {
                                    ID = brand.ID,
                                    Text = brand.BrandName,
                                    Url = "Picture/" + brand.ID,
                                    Level = 4
                                });
                        }
                    }
                }
            }

            return pictureCategories;
        }
        /// <summary>
        ///  获取面包屑
        /// </summary>
        /// <param name="productID"></param>
        /// <returns></returns>
        public string GetProductLevel(int brandID)
        {
            Product_Brand brand = new ProductBrandService().QueryById(brandID);
            if (brand == null) return "";

            StringBuilder sb = new StringBuilder();
            sb.Append("您当前的位置: <a href=\"" + Common.ConstantParams.IndexUrl + "\">首页</a>&nbsp;&gt;&nbsp;");
            sb.Append("<a href=\"/Home/Search?Brand=" + brand.BrandNameSpell + "\">" + brand.BrandName + "</a>");
            return sb.ToString();
        }
        /// <summary>
        /// The query picture tree view.
        /// </summary>
        /// <param name="id">
        /// The id.
        /// </param>
        /// <returns>
        /// The <see cref="JsonResult"/>.
        /// </returns>
        public JsonResult QueryPictureTreeView(int? id)
        {
            this.productCategoryService = new ProductCategoryService();
            this.productBrandService = new ProductBrandService();

            int totalCount;
            int pageCount;

            var modelList = new List<dynamic>();

            if (id == null)
            {
                id = 0;
                var condition = string.Format("ParentID = {0} And Layer = 1 ", id);

                var paging = new Paging("[Product_Category]", null, "ID", condition, 1, 100);
                var list = this.productCategoryService.Query(paging, out pageCount, out totalCount);
                if (list != null)
                {
                    foreach (var category in list)
                    {
                        modelList.Add(
                            new { id = category.ID.ToString(), Name = category.CategoryName, hasChildren = true, type = 1 });
                    }
                }

                TempData["TreeviewType"] = 1;
            }
            else
            {
                if (Convert.ToInt32(TempData["TreeviewType"]) == 1)
                {
                    var condition = string.Format("ParentID = {0} And Layer = 2 ", id);

                    var paging = new Paging("[Product_Category]", null, "ID", condition, 1, 100);
                    var list = this.productCategoryService.Query(paging, out pageCount, out totalCount);
                    if (list != null)
                    {
                        foreach (var category in list)
                        {
                            modelList.Add(
                                new { id = category.ID.ToString(), Name = category.CategoryName, hasChildren = true, type = 2 });
                        }
                    }

                    TempData["TreeviewType"] = 2;
                }
                else if (Convert.ToInt32(TempData["TreeviewType"]) == 2)
                {
                    var condition = string.Format("ProductCategoryID = {0} And ParentID = 0 ", id);

                    var paging = new Paging("[Product_Brand]", null, "ID", condition, 1, 100);
                    var list = this.productBrandService.Query(paging, out pageCount, out totalCount);
                    if (list != null)
                    {
                        foreach (var brand in list)
                        {
                            modelList.Add(new { id = brand.ID.ToString(), Name = brand.BrandName, hasChildren = true, type = 3 });
                        }
                    }

                    TempData["TreeviewType"] = 3;
                }
                else if (Convert.ToInt32(TempData["TreeviewType"]) == 3)
                {
                    var condition = string.Format("ParentID = {0}", id);

                    var paging = new Paging("[Product_Brand]", null, "ID", condition, 1, 100);
                    var list = this.productBrandService.Query(paging, out pageCount, out totalCount);
                    if (list != null)
                    {
                        foreach (var brand in list)
                        {
                            modelList.Add(new { id = brand.ID.ToString(), Name = brand.BrandName, hasChildren = false, type = 4 });
                        }
                    }
                }
            }

            return this.Json(modelList, JsonRequestBehavior.AllowGet);
        }