Esempio n. 1
0
        //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);
        }
Esempio n. 2
0
        //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);
        }
Esempio n. 3
0
        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);
        }