Ejemplo n.º 1
0
        public async Task <IActionResult> GetBookmarks(PagingInfo pagingInfo)
        {
            var bookmark = await _BookmarkRepository.GetAll(pagingInfo);

            IEnumerable <BookmarkListModel> model = bookmark.Select(que => CreateBookmarkListModel(que));

            var total = _BookmarkRepository.Count();
            var pages = (int)Math.Ceiling(total / (double)pagingInfo.PageSize);

            var prev = pagingInfo.Page > 0
                                 ? Url.Link(nameof(GetBookmark),
                                            new { page = pagingInfo.Page - 1, pagingInfo.PageSize })
                : null;

            var next = pagingInfo.Page < pages - 1
                                 ? Url.Link(nameof(GetBookmark),
                                            new { page = pagingInfo.Page + 1, pagingInfo.PageSize })
                : null;

            var result = new
            {
                Prev      = prev,
                Next      = next,
                Total     = total,
                Pages     = pages,
                Bookmarks = model
            };

            return(Ok(result));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> GetBookmarks(PagingInfo pagingInfo)
        {
            //var bookmark = await _BookmarkRepository.GetAll(pagingInfo);
            var bookmark = await _BookmarkRepository.GetBookmarks(pagingInfo);

            var model = bookmark.Select(que => CreateBookmarkListModel(que));

            var total = _BookmarkRepository.Count();
            var prev  = Url.Link(nameof(GetBookmarks), new { page = pagingInfo.Page - 1, pagingInfo.PageSize }).ToLower();
            var next  = Url.Link(nameof(GetBookmarks), new { page = pagingInfo.Page + 1, pagingInfo.PageSize }).ToLower();

            var returnType = new ReturnTypeConstants("bookmarks");
            var result     = PagingHelper.GetPagingResult(pagingInfo, total, model, returnType, prev, next);

            return(Ok(result));
        }