public async Task <IEnumerable <RssFeedViewModel> > GetAllAsync(int page = 1) { var newsFeeds = await _feedSource.GetAllNewsAsync().ConfigureAwait(false); #if DEBUG await Task.Delay(TimeSpan.FromSeconds(1)).ConfigureAwait(false); #endif var feedVms = newsFeeds.Select(Mapper.Map <RssFeedViewModel>).OrderByDescending(rssModel => rssModel.NewsDate) .Skip((page - 1) * _pagingConfiguration.PageSize) .Take(_pagingConfiguration.PageSize); return(feedVms); }
public async Task <ActionResult> IndexAsync(int page = 1) { var newsFeeds = await _feedSource.GetAllNewsAsync().ConfigureAwait(false); var feedVms = newsFeeds.Select(Mapper.Map <RssFeedViewModel>).ToList(); // PERFORMANCE-NOTE: На каждой странице приходится запрашивать все данные по новостям var navigationVm = new NavigationViewModel <RssFeedViewModel> { PageElements = feedVms.OrderByDescending(model => model.NewsDate).Skip((page - 1) * _PageSize).Take(_PageSize), Navigator = new PagingNavigator { CurrentPageNumber = page, ItemsPerPageCount = _PageSize, TotalItemsCount = feedVms.Count } }; return(View(navigationVm)); }