public async Task <IEnumerable <FilmCommentForListDto> > GetAll(FilmCommentFilterDto filmCommentFilter) { var filmComments = await _uow.Repository <Domain.Entities.FilmComment>().FindAsyncWithPagination(new FilmCommentWithUsersFilterPaginatedSpecification(filmCommentFilter)); _context.HttpContext.Response.AddPagination(filmComments.CurrentPage, filmComments.PageSize, filmComments.TotalCount, filmComments.TotalPages); var filmCommentsToReturn = _mapper.Map <IEnumerable <FilmCommentForListDto> >(filmComments); await _photoService.IncludeMainPhoto(filmCommentsToReturn.Select(x => x.User), (int)EntityTypes.User); return(filmCommentsToReturn); }
public FilmCommentWithUsersFilterPaginatedSpecification(FilmCommentFilterDto filmCommentFilter) : base(x => filmCommentFilter.FilmId == null || x.FilmId == filmCommentFilter.FilmId) { if (filmCommentFilter.OrderByDescending == nameof(Domain.Entities.FilmComment.CreatedAt)) { ApplyOrderByDescending(x => x.CreatedAt); } ApplyPaging(filmCommentFilter.Skip, filmCommentFilter.Take, filmCommentFilter.PageNumber); AddInclude($"{nameof(Domain.Entities.FilmComment.User)}"); }
public async Task <IActionResult> GetAll([FromQuery] FilmCommentFilterDto filmCommentFilter) { return(Ok(await _filmCommentService.GetAll(filmCommentFilter))); }