/// <summary>
        /// 编辑新闻类别信息
        /// </summary>
        /// <param name="newsClassifyModel">新闻类别视图模型</param>
        /// <returns>响应实体模型</returns>
        public ResponseModel EditNewsClassify(NewsClassifyModel newsClassifyModel)
        {
            var NewsClassify = newsClassifyRepository.GetbyId(newsClassifyModel.Id);

            if (NewsClassify == null)
            {
                return new ResponseModel {
                           code = 0, message = "新闻类别不存在"
                }
            }
            ;
            try
            {
                NewsClassify.Id = newsClassifyModel.Id;

                NewsClassify.Name   = newsClassifyModel.Name;
                NewsClassify.Sort   = Convert.ToInt32(newsClassifyModel.Sort);
                NewsClassify.Remark = newsClassifyModel.Remark;
            }
            catch { return(new ResponseModel {
                    code = 0, message = "修改内部错误,青重新编辑"
                }); }
            bool edit = newsClassifyRepository.ModifyEntity(NewsClassify);

            if (edit == false)
            {
                return new ResponseModel {
                           code = 0, message = "修改失败"
                }
            }
            ;
            return(new ResponseModel {
                code = 200, message = "修改成功"
            });
        }
        /// <summary>
        /// 添加新闻信息信息
        /// </summary>
        /// <param name="newsClassifyModel">新闻类别视图模型</param>
        /// <returns>响应实体模型</returns>
        public ResponseModel NewsClassifyAdd(NewsClassifyModel newsClassifyModel)
        {
            NewsClassify newsClassify = new NewsClassify();

            try
            {
                int n = newsClassifyRepository.GetMaxClassifyId();

                newsClassify.Id     = n + 1;
                newsClassify.Name   = newsClassifyModel.Name;
                newsClassify.Sort   = Convert.ToInt32(newsClassifyModel.Sort);
                newsClassify.Remark = newsClassifyModel.Remark;
            }
            catch { return(new ResponseModel {
                    code = 0, message = "信息添加过程失败,请重新填写"
                }); }
            bool add = newsClassifyRepository.AddEntity(newsClassify);

            if (add == false)
            {
                return new ResponseModel {
                           code = 0, message = "添加失败"
                }
            }
            ;
            return(new ResponseModel {
                code = 200, message = "添加成功"
            });
        }
    }
Exemple #3
0
 public JsonResult NewsClassifyEdit(NewsClassifyModel newsClassifyModel)
 {
     //判断Id
     if (newsClassifyModel.Id <= 0)
     {
         return(Json(new ResponseModel {
             code = 0, message = "请填写新闻类别序号"
         }));
     }
     return(Json(newsClassifyServices.EditNewsClassify(newsClassifyModel)));
 }
Exemple #4
0
 public JsonResult NewsClassifyAdd(NewsClassifyModel newsClassifyModel)
 {
     return(Json(newsClassifyServices.NewsClassifyAdd(newsClassifyModel)));
 }