public ActionResult Show(string id) { this.Internationalization(); NewsModel model = new NewsModel(); if (string.IsNullOrEmpty(id)) { id = "1"; } NewsService newsService = new NewsService(); model.News = newsService.GetNewsById(Int32.Parse(id)); //随机推荐 //model.RecommendRandoms = newsService.GetRecommendRandom(6); //猜你喜欢 //VideoService videoService = new VideoService(); //model.Like = videoService.GetLike(16); //推荐新闻 //model.RecommendNews = NewsService.GetRecommendRandom(10); //推荐小说 //model.RecommendNovels = NovelService.GetRecommendRandom(10); if (model.News == null) { model.News = new Model.News(); model.News.Title = "该新闻不存在或已被删除"; } else { AlbumService albumService = new AlbumService(); int outCount = 0; model.RelatedAlbum = albumService.GetAlbumList(string.Empty, model.News.Keywords, 8, 1, out outCount); model.RelatedNews = newsService.GetRelatedNews(model.News.Id); } return View(model); }
public ActionResult Show(string id) { this.Internationalization(); NewsModel model = new NewsModel(); if (string.IsNullOrEmpty(id)) { id = "1"; } NewsService newsService = new NewsService(); model.News = newsService.GetNewsById(Int32.Parse(id)); if (model.News == null) { model.News = new Model.News(); model.News.Title = "该新闻不存在或已被删除"; } else { AlbumService albumService = new AlbumService(); int outCount = 0; model.RelatedAlbum = albumService.GetAlbumList(string.Empty, model.News.Keywords, 5, 1, out outCount); model.RelatedNews = newsService.GetRelatedNews(model.News.Id); model.LastNews = newsService.GetPrvNewsById(model.News.Id); model.NextNews = newsService.GetNextNewsById(model.News.Id); } return View(model); }
public ActionResult Edit(int id) { if (Session["UserId"] == null) { return Redirect("/admin/login"); } NewsModel model = new NewsModel(); NewsService newsService = new NewsService(); model.NewsCategories = newsService.GetNewsCategories(); model.News = newsService.GetNewsById(id); if (model.News != null && !model.News.IsActive) { model.News = null; } if (model.News == null) { model.News = new News(); } return View(model); }