public ParameterEntity Update (ParameterEntity entity) { try { _parameterRepository.Update(entity); return entity; } catch (Exception e) { _log.Error(e,"数据库操作出错"); return null; } }
public bool Delete(ParameterEntity entity) { try { _parameterRepository.Delete(entity); return true; } catch (Exception e) { _log.Error(e,"数据库操作出错"); return false; } }
/// <summary> /// 添加参数 /// </summary> /// <param name="model"></param> /// <returns></returns> public HttpResponseMessage Post(ParameterModel model) { if(String.IsNullOrEmpty(model.Name) || model.Id==0) { return PageHelper.toJson(PageHelper.ReturnValue(false, "数据异常!")); } var entity = new ParameterEntity { Category = _categoryService.GetCategoryById(model.Id),//添加时候 这里的Id传的是分类ID Name = model.Name, Sort = model.Sort, AddTime =DateTime.Now, UpdTime =DateTime.Now, }; if(_parameterService.Create(entity).Id > 0) { return PageHelper.toJson(PageHelper.ReturnValue(true, "添加成功!")); } return PageHelper.toJson(PageHelper.ReturnValue(false, "添加失败!")); }