Пример #1
0
        public IList <Questions> GetQuestions(PagingAttributes pagingAttributes)
        {
            //// for browsing the full list of questions
            using var db = new DatabaseContext();

            //convert back from 1-based pages + check/fix page
            int page = _sharedService.GetPagination(_sharedService.NumberOfQuestions(), pagingAttributes);

            return(db.Questions
                   .OrderBy(u => u.Id)
                   .Skip(page * pagingAttributes.PageSize)
                   .Take(pagingAttributes.PageSize)
                   .ToList());
        }
Пример #2
0
        public (List <Searches>, int) GetSearchesList(int userId, PagingAttributes pagingAttributes)
        {
            using var db = new DatabaseContext();

            var count = db.Searches
                        .Where(x => x.UserId == userId)
                        .OrderByDescending(x => x.Date)
                        .Count();

            //try to convert back from 1-based pages
            int page = _sharedService.GetPagination(count, pagingAttributes);

            var list = db.Searches
                       .Where(x => x.UserId == userId)
                       .OrderByDescending(x => x.Date)
                       .Skip(page * pagingAttributes.PageSize)
                       .Take(pagingAttributes.PageSize)
                       .ToList();

            return(list, count);
        }