public async Task <ActionResult <IEnumerable <UFileReturnDto> > > GetAllFilesFromUser([FromQuery] PageUserParams userParams) { int userId = int.Parse(User.FindFirst(ClaimTypes.NameIdentifier).Value); // var files = await _fileRepo.GetFilesFromUser(userId); var files = await _fileRepo.GetFilesFromUserPaged(userId, userParams); var filesToReturn = _mapper.Map <IEnumerable <UFileReturnDto> >(files); Response.AddPagination(new PaginationHeader() { CurrentPage = files.CurrentPage, ItemsPerPage = files.PageSize, TotalItems = files.TotalCount, TotalPages = files.TotalPages }); return(Ok(filesToReturn)); }
public async Task <PagedList <UFile> > GetFilesFromUserPaged(int userId, PageUserParams userParams) { var users = _context.UFiles.Where(f => f.OwnerId == userId).OrderByDescending(o => o.DateAdded); return(await PagedList <UFile> .CreateAsync(users, userParams.PageNumber, userParams.PageSize)); }