public async Task <IActionResult> GetAll(BlogCommentRequest request) { var allRates = await _blogCommentService.GetAllPaging(request); return(new OkObjectResult(allRates)); }
public IActionResult GetAll(BlogCommentRequest request) { var allRates = _blogCommentService.GetAllPaging(request); return(new OkObjectResult(allRates)); }
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 }); }