Ejemplo n.º 1
0
        public HttpResponseMessage AddProductBrand([FromBody] ProductBrandModel productBrandModel)
        {
            Regex reg = new Regex(@"^[^ %@#!*~&',;=?$\x22]+$");
            var   m   = reg.IsMatch(productBrandModel.Bname);

            if (!m)
            {
                return(PageHelper.toJson(PageHelper.ReturnValue(false, "存在非法字符!")));
            }
            else
            {
                ProductBrandEntity pbe = new ProductBrandEntity()
                {
                    Addtime  = DateTime.Now,
                    Adduser  = _workContext.CurrentUser.Id.ToString(CultureInfo.InvariantCulture),
                    Bimg     = productBrandModel.Bimg,
                    Bname    = productBrandModel.Bname,
                    Updtime  = DateTime.Now,
                    Upduser  = _workContext.CurrentUser.Id.ToString(CultureInfo.InvariantCulture),
                    SubTitle = productBrandModel.SubTitle,
                    Content  = productBrandModel.Content,
                    AdTitle  = productBrandModel.AdTitle,
                    ClassId  = productBrandModel.ClassId
                };

                try
                {
                    _productBrandService.Create(pbe);
                    return(PageHelper.toJson(PageHelper.ReturnValue(true, "添加成功!")));
                }
                catch (Exception)
                {
                    return(PageHelper.toJson(PageHelper.ReturnValue(false, "不能添加自身!")));
                }
            }
        }