public async Task <IActionResult> GetList([FromQuery] SimplePaginationModel pagination) { return(await this.Execute(false, true, async() => { NewsListPaginatedModel result = await this.news.GetList(pagination); return this.Ok(result); })); }
public async Task <NewsListPaginatedModel> GetList(SimplePaginationModel pagination) { IEnumerable <NewsListModel> news = this.db.News .OrderByDescending(n => n.CreationDate) .ProjectTo <NewsListModel>() .ToList(); int newsCount = news.Count(); news = news.Skip(pagination.Size * (pagination.Page - 1)).Take(pagination.Size).ToList(); return(new NewsListPaginatedModel { News = news, NewsCount = newsCount }); }