public IEnumerable <ProductEntity> GetProductList(ProductQueryEntity model)
        {
            Dictionary <string, object> dic = new Dictionary <string, object>();

            if (!string.IsNullOrEmpty(model.CategoryIds))
            {
                dic.Add("@CategoryIds", model.CategoryIds);
            }
            if (model.VendorId > 0)
            {
                dic.Add("@VendorId", model.VendorId);
            }
            if (!string.IsNullOrEmpty(model.Key))
            {
                dic.Add("@Keywords", model.Key);
            }
            dic.Add("@PageIndex", model.PageIndex);
            dic.Add("@PageSize", model.PageSize);

            IEnumerable <ProductEntity> list = null;
            var reader = GetReader("[GetProductPageList]", dic, System.Data.CommandType.StoredProcedure);

            if (reader != null)
            {
                model.Total = reader.Read <int>().FirstOrDefault();
                list        = reader.Read <Product, Picture, ProductEntity>((p, pp) => new ProductEntity(p, pp), new string[] { "PP" }).ToList();
            }
            return(list);
        }
        public ActionResult Index(ProductQueryEntity model)
        {
            //if (model == null) model = new ProductQueryEntity();
            //var list = productService.GetProductList(model);
            ViewBag.QueryModel = model;

            return(View());
        }
        public ActionResult GetProductList(ProductQueryEntity model)
        {
            if (model == null)
            {
                model = new ProductQueryEntity();
            }

            var list = productService.GetProductList(model);

            return(Json(new { Data = list, PageCount = model.GetTotalPageCount() }));
        }
Esempio n. 4
0
        public IEnumerable <ProductEntity> GetProductList(ProductQueryEntity model)
        {
            var list = productRep.GetProductList(model);

            if (list != null)
            {
                foreach (var item in list)
                {
                    item.Product.ShortDescription = UtilityHepler.LostHTML(item.Product.ShortDescription);
                    if (item.Picture != null && item.Picture.Id > 0)
                    {
                        item.ProductPicURL = pictureService.GetPictureUrl(item.Picture, ProductEntity.ProductThumbPictureSize);
                    }
                }
            }
            return(list);
        }