/// <summary> /// Update a news category /// </summary> /// <param name="newsClassify"></param> /// <returns></returns> public ResponseModel EditNewsClassify(EditNewsClassify newsClassify) { var classify = this.GetOneNewsClassify(c => c.Id == newsClassify.Id); if (classify == null) { return new ResponseModel { code = 0, result = "This category does not existed" } } ; classify.Name = newsClassify.Name; classify.Sort = newsClassify.Sort; classify.Remark = newsClassify.Remark; _db.NewsClassify.Update(classify); int i = _db.SaveChanges(); if (i > 0) { return new ResponseModel { code = 200, result = "Category update succ!" } } ; return(new ResponseModel { code = 0, result = "Category update fail" }); }
public ResponseModel EditNewsClassify(EditNewsClassify newsClassify) { var classify = this.GetOneNewsClassify(c => c.Id == newsClassify.Id); if (classify == null) { return new ResponseModel { code = 0, result = "新闻类别不存在" } } ; classify.Name = newsClassify.Name; classify.Sort = newsClassify.Sort; classify.Remark = newsClassify.Remark; _db.NewsClassify.Update(classify); int i = _db.SaveChanges(); if (i > 0) { return(new ResponseModel { code = 200, result = "新闻类别修改成功" }); } else { return(new ResponseModel { code = 0, result = "新闻类别修改失败" }); } }
public ResponseModel EditNewsClassify(EditNewsClassify newsClassify) { var classify = GetOneNewsClassify(c => c.Id == newsClassify.Id); if (classify == null) { return(new ResponseModel { code = 0, result = "This classify has not existed!" }); } classify.Name = newsClassify.Name; classify.Remark = newsClassify.Remark; classify.Sort = newsClassify.Sort; _db.NewsClassify.Update(classify); int i = _db.SaveChanges(); if (i > 0) { return(new ResponseModel { code = 200, result = "NewsClassify edit success!" }); } return(new ResponseModel { code = 0, result = "NewsClassify edit failed!" }); }
/// <summary> /// 编辑一个新闻类别 /// </summary> public ResponseModel EditNewsClassify(EditNewsClassify newsClassify) { // 这里的GetOneNewsClassify调用的即是根据条件获取新闻类别的方法,将数据库新闻类型的id与获取到的id对比再做判断 var classify = this.GetOneNewsClassify(c => c.Id == newsClassify.Id); // 空值判断及操作 if (classify == null) { return new ResponseModel { code = 0, result = "该类别不存在" } } ; // 非空值下进行赋值,赋值类型来源于将EditNewsClassify类 classify.Name = newsClassify.Name; classify.Sort = newsClassify.Sort; classify.Remark = newsClassify.Remark; // 赋值完成即可更新数据库 _db.NewsClassify.Update(classify); int i = _db.SaveChanges(); if (i > 0) { return new ResponseModel { code = 200, result = "新闻类别编辑成功" } } ; return(new ResponseModel { code = 0, result = "新闻类别编辑失败" }); }
/// <summary> /// 编辑新闻类别 /// </summary> /// <param name="editNewsClassify"></param> /// <returns></returns> public ResponseModel EditNewsClassify(EditNewsClassify editNewsClassify) { var classify = GetOneNewsClassify(x => x.Id == editNewsClassify.ID); if (classify == null) { return new ResponseModel { code = 0, result = "NewsClassify不存在" } } ; classify.Name = editNewsClassify.Name; classify.Sort = editNewsClassify.Sort; classify.Remark = editNewsClassify.Remark; _db.NewsClassify.Update(classify); int i = _db.SaveChanges(); if (i > 0) { return new ResponseModel { code = 200, result = "NewsClassify更新成功" } } ; else { return new ResponseModel { code = 0, result = "NewsClassify更新失败" } }; }
public JsonResult NewsClassifyEdit(EditNewsClassify newsClassify) { if (string.IsNullOrEmpty(newsClassify.Name)) { return(Json(new ResponseModel { code = 0, result = "请输入新闻类别名称" })); } return(Json(_newsService.EditNewsClassify(newsClassify))); }
public JsonResult NewsClassifyEdit(EditNewsClassify newsClassify) { if (string.IsNullOrEmpty(newsClassify.Name)) { return(Json(new ResponseModel { code = 0, result = "Category name is invalid" })); } return(Json(_newsService.EditNewsClassify(newsClassify))); }
public JsonResult EditNewsClassify(EditNewsClassify edit_newsClassify) { //标题名称不能为空 if (string.IsNullOrEmpty(edit_newsClassify.Name)) { return(Json(new ResponseModel { code = 0, result = "类别标题不能为空!" })); } return(Json(_newsService.EditNewsClassify(edit_newsClassify))); }