//This method retrives the latest news by its category public News GetMostRecentSingleNewsByCategory(NewsCategoryEnum categoryType) { var newsList = _db.News.Where(n => n.NewsCategory.Name == categoryType.ToString()); var latestNews = newsList.OrderByDescending(n => n.DateCreated).FirstOrDefault(); return(latestNews); }
//This method retrives a list of news by its category public IEnumerable <News> GetLatestNewsByCategory(NewsCategoryEnum categoryType, int number) { var news = _db.News.Where(n => n.NewsCategory.Name == categoryType.ToString()); var newList = news.OrderByDescending(n => n.DateCreated); var latestNews = newList.Take(number); return(latestNews); }
public IEnumerable <News> GetTopNthPopularNewsForCategory(NewsCategoryEnum categoryTyp, int number) { var newsList = _db.News.ToList(); var newsCategory = newsList.Where(n => n.NewsCategory.Name == categoryTyp.ToString()); var orderedNews = newsCategory.OrderByDescending(n => n.NewsView); var news = orderedNews.Take(number); return(news); }