Ejemplo n.º 1
0
        public HttpResponseMessage GetAllBrand(int page = 1, int pageSize = 10, string className = null, bool isDes = true, EnumProductBrandSearchOrderBy orderByAll = EnumProductBrandSearchOrderBy.OrderByAddtime)
        {
            var con = new ClassifySearchCondition()
            {
                Name = className
            };
            var classname = _classifyService.GetClassifysByCondition(con).FirstOrDefault();

            //参数className 不传值则默认查询所有品牌
            if (string.IsNullOrEmpty(className))
            {
                classname = null;
            }


            var sech = new ProductBrandSearchCondition
            {
                //=========================yangyue 2015/7/7 start=====================================================
                IsDescending = isDes,
                OrderBy      = orderByAll,
                Classify     = classname,

                //========================  end   ====================================================================
                Page      = page,
                PageCount = pageSize
            };
            // var list = _productBrandService.GetProductBrandsByCondition(sech).Select(a => new
            //{
            //    Page = page,
            //    PageCount = pageSize,
            //});
            //取出所有品牌
            var list = _productBrandService.GetProductBrandsByCondition(sech).Select(a => new

            {
                a.Id,
                a.Bimg,
                a.Bname,
                a.SubTitle,
                a.Content,
                a.Addtime,
                a.AdTitle,
                ProductParamater = a.ParameterEntities.Select(p => new { p.Parametername, p.Parametervaule })
            }).ToList().Select(b => new
            {
                b.Id,
                b.Bimg,
                b.Bname,
                b.SubTitle,
                b.Content,
                b.AdTitle,
                ProductParamater = b.ProductParamater.ToDictionary(k => k.Parametername, v => v.Parametervaule),
                b.Addtime
            });

            var totalCount1 = _productBrandService.GetProductBrandCount(sech);


            return(PageHelper.toJson(new { List = list, Condition = sech, totalCount = totalCount1 }));

            //var totalCount = _productBrandService.GetProductBrandCount(Brandcondition);

            //var BrandList = _productBrandService.GetProductBrandsByCondition(Brandcondition).Select(a => new
            //{
            //    a.Id,
            //    a.Bimg,
            //    a.Bname,
            //    a.SubTitle,
            //    a.Content,
            //    ProductParamater = a.ParameterEntities.Select(p => new { p.Parametername, p.Parametervaule })
            //}).ToList();
            //return PageHelper.toJson(new { brandList = BrandList.Select(b => new {
            //    b.Id,
            //    b.Bimg,
            //    b.Bname,
            //    b.SubTitle,
            //    b.Content,
            //    ProductParamater=b.ProductParamater.ToDictionary(k=>k.Parametername,v=>v.Parametervaule)
            //}), totalCount = totalCount });
            ////return PageHelper.toJson(_productBrandService.GetProductBrandsByCondition(PBSC).ToList());
        }