public ActionResult ViewNewsById(int id) { NewsService service = new NewsService(); News item = service.GetById(id); List<News> relatedNews = service.GetRelatedNews(item.NewsID); ContentViewNewsModel model = new ContentViewNewsModel() { Category = item.Category, NewsItem = item, SubCategories = item.Category.Categories1.ToList(), RelatedNews = relatedNews }; return View(model); }
//[AllowAccess] public ActionResult ViewNews(string news) { NewsService service = new NewsService(); News item = service.GetNewsByKey(news); if (item.ViewCount.HasValue) { item.ViewCount = item.ViewCount++; } else { item.ViewCount = 1; } List<News> relatedNews = service.GetRelatedNews(item.NewsID); ContentViewNewsModel model = new ContentViewNewsModel() { Category = item.Category, NewsItem = item, SubCategories = item.Category.Categories1.ToList(), RelatedNews = relatedNews }; return View(model); }