Esempio n. 1
0
 public HttpResponseMessage GetBrandDetail(int brandId)
 {
     var brand = _productBrandService.GetProductBrandById(brandId);
     if(brand==null)
     {
         return PageHelper.toJson(PageHelper.ReturnValue(false, "品牌不存在"));
     }
     var model = new ProductBrandModel
     {   
         Id = brand.Id,               
         Bname = brand.Bname,
         SubTitle = brand.SubTitle,                
         Content = brand.Content,
         Parameters = brand.ParameterEntities.ToDictionary(k => k.Parametername, v => v.Parametervaule)
     };
     return PageHelper.toJson(model);
 }
Esempio n. 2
0
        public HttpResponseMessage GetByBrandId(int brandId)
        {
            var brand = _productBrandService.GetProductBrandById(brandId);
            var model = new ProductBrandModel
            {
                Addtime = brand.Addtime,
                Adduser = brand.Adduser,
                Bimg = brand.Bimg,
                Bname = brand.Bname,
                SubTitle = brand.SubTitle,
                Id = brand.Id,
                Content = brand.Content,
                AdTitle = brand.AdTitle,
               ClassId = brand.ClassId.HasValue?brand.ClassId.Value:0,

                //Parameters = Brand.ParameterEntities.Select(p => new ProductBrandParameterModel
                //{
                //    Parametername = p.Parametername,
                //    Parametervaule = p.Parametervaule
                //}).ToList()
                Parameters = brand.ParameterEntities.ToDictionary(k => k.Parametername, v => v.Parametervaule)
            };
            var products = _productService.GetProductsByProductBrand(brand.Id);
            model.Products = products.Select(p => new ProductModel
            {
                Productname = p.Productname,
                Id = p.Id,
                Productimg = p.Productimg
            }).ToList();
            return PageHelper.toJson(model);
        }
Esempio n. 3
0
        public HttpResponseMessage UpProductBrand(ProductBrandModel productBrandModel)
        {
            Regex reg = new Regex(@"^[^ %@#!*~&',;=?$\x22]+$");
            var m = reg.IsMatch(productBrandModel.Bname);
            if (!m)
            {
                return PageHelper.toJson(PageHelper.ReturnValue(false, "存在非法字符!"));
            }
            else
            {
                var pb = _productBrandService.GetProductBrandById(productBrandModel.Id);
                pb.Updtime = DateTime.Now;
                pb.Bname = productBrandModel.Bname;
                pb.Upduser = _workContext.CurrentUser.Id.ToString(CultureInfo.InvariantCulture);
                pb.SubTitle = productBrandModel.SubTitle;
                pb.Content = productBrandModel.Content;
                pb.Bimg = productBrandModel.Bimg;
                pb.AdTitle = productBrandModel.AdTitle;
                pb.ClassId = productBrandModel.ClassId;
                if (_productBrandService.Update(pb) != null)
                {
                    return PageHelper.toJson(PageHelper.ReturnValue(true, "数据修改成功!"));
                }

                else
                {
                    return PageHelper.toJson(PageHelper.ReturnValue(false, "数据更新失败!"));
                }
            }
        }