Exemplo n.º 1
0
        public async Task <PaginatedListActionResult <ProblemListInfo> > GetProblemList(
            [FromQuery] ProblemSortKey by = ProblemSortKey.ArchiveId,
            [FromQuery] bool descend      = false,
            [FromQuery][Page] int page    = 0,
            [FromQuery][ItemsPerPage] int itemsPerPage = 20)
        {
            var findPipeline = new ProblemFindPipeline(new ProblemFilterBuilder().InArchive(true))
            {
                SortKey          = by,
                SortByDescending = descend,
                Pagination       = new Pagination(page, itemsPerPage)
            };
            var findResult = await _repo.Problems.FindManyAsync(findPipeline);

            var models = findResult.ResultSet.Select(p => _mapper.Map <Problem, ProblemListInfo>(p));

            return(findResult.TotalCount, models);
        }
Exemplo n.º 2
0
        public async Task <PaginatedListActionResult <ProblemListInfo> > GetProblems(
            [FromQuery] ProblemSortKey by = ProblemSortKey.CreationTime,
            [FromQuery] bool descend      = true,
            [FromQuery][Range(0, int.MaxValue)] int page         = 0,
            [FromQuery][Range(1, int.MaxValue)] int itemsPerPage = 20)
        {
            var findPipeline = new ProblemFindPipeline(ProblemFilterBuilder.Empty)
            {
                SortKey          = by,
                SortByDescending = descend,
                Pagination       = new Pagination(page, itemsPerPage)
            };

            var findResult = await _repo.Problems.FindManyAsync(findPipeline);

            var models = findResult.ResultSet.Select(e => _mapper.Map <Problem, ProblemListInfo>(e));

            return(findResult.TotalCount, models);
        }