Esempio n. 1
0
        /// <summary>
        /// 添加新闻
        /// </summary>
        /// <param name="news">添加的新闻实体</param>
        /// <returns>响应实体模型</returns>
        public ResponseModel AddNews(AddNews news)
        {
            News n;

            try
            {
                n = new News
                {
                    NewsClassifyId = news.NewsClassifyId.ToString(),
                    Title          = news.Title,
                    Image          = news.Image,
                    Contents       = news.Contents,
                    PublishDate    = DateTime.Now,
                    Remark         = news.Remark
                };
            }
            catch
            {
                return(new ResponseModel {
                    code = 0, message = "添加内部信息错误,请重新填写"
                });
            }
            bool add = newsRepository.AddEntity(n);

            if (add == false)
            {
                return new ResponseModel {
                           code = 0, message = "添加失败"
                }
            }
            ;
            return(new ResponseModel {
                code = 200, message = "添加成功"
            });
        }
    }