コード例 #1
0
        public async Task <IActionResult> GetAll(BlogCommentRequest request)
        {
            var allRates = await _blogCommentService.GetAllPaging(request);

            return(new OkObjectResult(allRates));
        }
コード例 #2
0
        public IActionResult GetAll(BlogCommentRequest request)
        {
            var allRates = _blogCommentService.GetAllPaging(request);

            return(new OkObjectResult(allRates));
        }
コード例 #3
0
        public async Task <BaseReponse <ModelListResult <BlogCommentViewModel> > > GetAllPaging(BlogCommentRequest request)
        {
            var query = await _blogCommentRepository.FindAll();

            if (request.BlogId > 0)
            {
                query = query.Where(x => x.BlogId == request.BlogId);
            }

            int totalRow = query.Count();

            query = query.OrderByDescending(x => x.DateCreated)
                    .Skip(request.PageIndex * request.PageSize)
                    .Take(request.PageSize);

            var items = new BlogCommentViewModel().Map(query).ToList();

            return(new BaseReponse <ModelListResult <BlogCommentViewModel> >
            {
                Data = new ModelListResult <BlogCommentViewModel>()
                {
                    Items = items,
                    Message = Message.Success,
                    RowCount = totalRow,
                    PageSize = request.PageSize,
                    PageIndex = request.PageIndex
                },
                Message = Message.Success,
                Status = (int)QueryStatus.Success
            });
        }