public ActionResult GetRelatedProducts(int categoryId)
        {
            var returnModel = new ProductDetailViewModel();

            returnModel.SStore           = MyStore;
            returnModel.SCategory        = ProductCategoryService.GetProductCategory(categoryId);
            returnModel.SRelatedProducts = ProductRepository.GetProductByTypeAndCategoryId(MyStore.Id, StoreConstants.ProductType, categoryId).Take(5).ToList();
            String partialViewName = @"pProducts\pRelatedProducts";
            var    html            = this.RenderPartialToString(partialViewName, new ViewDataDictionary(returnModel));



            return(Json(html, JsonRequestBehavior.AllowGet));
        }
Example #2
0
        public List <ComboTree> GetComboTreeCategory(int id)
        {
            IProductCategoryService productCategoryService = new ProductCategoryService();
            var data = productCategoryService.GetProductCategory();
            List <ComboTree> result = new List <ComboTree>();

            var root = data.Where(s => s.Depth == id);

            foreach (var categoryInfo in root)
            {
                var comboTree = new ComboTree();
                comboTree.Id       = categoryInfo.Id;
                comboTree.Text     = categoryInfo.Name;
                comboTree.Children = GetComboTreeChildren(comboTree, categoryInfo, data);
                result.Add(comboTree);
            }
            return(result);
        }
Example #3
0
        public object GetProductCategory()
        {
            IProductCategoryService productCategoryService = new ProductCategoryService();

            var data = productCategoryService.GetProductCategory();

            // 每页显示记录数
            int pageSize = 10;
            // 记录总数
            int rowCount = data.Count;
            // 总页数
            int pageCount = rowCount % pageSize == 0 ? rowCount / pageSize : rowCount / pageSize + 1;

            var resultObj = new JQGridDataResult
            {
                // 总页数
                PageCount = pageCount,
                // 当前页
                PageIndex = 1,
                // 总记录数
                Total = rowCount,
                // 数据
                Data = from item in data
                       select new
                {
                    cell = new string[]
                    {
                        item.Id.ToString(),
                item.Name,
                item.Desc,
                item.CategoryId.ToString(),
                item.MediumPicture,

                item.Depth.ToString(),
                item.Parent,
                        (item.Rgt == item.Lft + 1).ToString(),
                        "true",
                        "true"
                    }
                }
            };

            return(resultObj);
        }
Example #4
0
        public object DeleteProductCategoryById(int id)
        {
            IProductCategoryService productCategoryService = new ProductCategoryService();

            var productCategory = productCategoryService.GetProductCategoryById(id);

            if (productCategory != null)
            {
                //WHERE Lft BETWEEN @MyLeft AND @MyRight;
                var all =
                    productCategoryService.GetProductCategory().Where(
                        s => s.Lft >= productCategory.Lft && s.Rgt <= productCategory.Rgt);
                IProductService productService = new ProductService();
                foreach (ProductCategoryInfo productCategoryInfo in all)
                {
                    productService.DeleteProductByCategoryId(productCategory.Id);
                }
            }

            return(productCategoryService.DeleteById(id));
        }
Example #5
0
 public static IQueryable GetProductCategory()
 {
     return(ProductCategoryService.GetProductCategory());
 }
Example #6
0
        public object GetAllProductCategory()
        {
            IProductCategoryService productCategoryService = new ProductCategoryService();

            return(productCategoryService.GetProductCategory().Where(s => s.Depth != 0).ToList());
        }