public bool Delete(ClassifyEntity entity) { try { _classifyRepository.Delete(entity); return true; } catch (Exception e) { _log.Error(e,"数据库操作出错"); return false; } }
public ClassifyEntity Update (ClassifyEntity entity) { try { _classifyRepository.Update(entity); return entity; } catch (Exception e) { _log.Error(e,"数据库操作出错"); return null; } }
public HttpResponseMessage AddClassify([FromBody]ClassifyModel classify) { Regex reg = new Regex(@"^[^ %@#!*~&',;=?$\x22]+$"); var m = reg.IsMatch(classify.Name); if (!m) { return PageHelper.toJson(PageHelper.ReturnValue(false, "存在非法字符!")); } ClassifyEntity superCe = _classifyService.GetClassifyById(classify.ClassifyId); int sort = 0; if (superCe != null)//有上级分类则次级排序加1; { sort = superCe.Sort + 1; } ClassifyEntity ce = new ClassifyEntity() { Classify = superCe, Name = classify.Name, Sort = sort, Addtime = DateTime.Now, // Adduser = classify.Adduser, Adduser = _workContext.CurrentUser.Id.ToString(), Updtime = DateTime.Now, Upduser = _workContext.CurrentUser.Id.ToString() //Upduser = classify.Upduser }; try { _classifyService.Create(ce); return PageHelper.toJson(PageHelper.ReturnValue(true, "添加分类成功!")); } catch (Exception error) { return PageHelper.toJson(PageHelper.ReturnValue(false, "添加分类失败!")); ; } }