示例#1
0
        /// <summary>
        /// Returns list of all news items paged within envelope with appropriate link relations
        /// </summary>
        /// <param name="pageNumber">Which number of page to fetch news items of</param>
        /// <param name="pageSize">How many news items to display per page</param>
        /// <returns>list of all news items in descending order encapsulated in envelope for paging info</returns>
        public Envelope <NewsItemDto> GetAllNewsItems(int PageNumber, int PageSize)
        {
            var allNewsItems = _newsItemRepository.GetAllNewsItems();
            IEnumerable <NewsItemDto> pagedNewsItems = PageService <NewsItemDto> .PageData(allNewsItems, PageNumber, PageSize);

            foreach (var n in pagedNewsItems)
            {
                n.AddReferences(n.Id, getCategories(n.Id), getAuthors(n.Id));
            }
            return(new Envelope <NewsItemDto>
            {
                Items = PageService <NewsItemDto> .PageData(allNewsItems, PageNumber, PageSize),
                PageNumber = PageNumber,
                PageSize = PageSize,
                MaxPages = PageService <NewsItemDto> .GetMaxPages(allNewsItems.Count(), PageSize)
            });
        }
        public void GetAllNewsItems_ShouldReturnAListOfTwo()
        {
            var newsItem = _repository.GetAllNewsItems();

            Assert.AreEqual(newsItem.Count(), 2);
        }
 public IEnumerable <NewsItemDTO> GetAllNewsItems()
 {
     return(Mapper.Map <IEnumerable <NewsItemDTO> >(_repo.GetAllNewsItems()));
 }