public bool Delete(ProductBrandEntity entity) { try { _productbrandRepository.Delete(entity); return true; } catch (Exception e) { _log.Error(e, "数据库操作出错"); return false; } }
public ProductBrandEntity Update(ProductBrandEntity entity) { try { _productbrandRepository.Update(entity); return entity; } catch (Exception e) { _log.Error(e, "数据库操作出错"); return null; } }
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, "不能添加自身!")); } } }