Esempio n. 1
0
        public async Task <PagedList <Note> > GetNotesByDescending(NoteParams noteParams)
        {
            var returnValues = await noteRepository.IncludeAsyncForNoteByDescending(noteParams, x => x.Photos, x => x.Id);

            //it should be queryable due to pagedlist
            // var notes = returnValues.Result.AsQueryable();
            //return await PagedList<Note>.CreateAsync(notes, noteParams.PageNumber, noteParams.PageSize);
            return(returnValues);
        }
Esempio n. 2
0
        public async Task <IActionResult> GetNotes([FromQuery] NoteParams noteParams)
        {
            var notes = await noteManager.GetNotesByDescending(noteParams);

            Response.AddPagination(notes.CurrentPage, notes.PageSize, notes.TotalCount, notes.TotalPages);

            // var categoryToReturn = mapper.Map<UserDetailModel>(category);

            return(Ok(notes));
        }
        public async Task <PagedList <T> > IncludeAsyncForNoteByDescending(NoteParams noteParams, Expression <Func <T, object> > includeFilter, Expression <Func <T, object> > descendingFilter)
        {
            var list = await dbSetObject.Include(includeFilter).OrderByDescending(descendingFilter).ToListAsync();

            var queryableList = list.AsQueryable();

            PagedList <T> returnValues = PagedList <T> .CreateAsync(queryableList, noteParams.PageNumber, noteParams.PageSize);

            //return await PagedList<T>.CreateAsync(queryableList, noteParams.PageNumber, noteParams.PageSize);
            return(returnValues);
        }
        public async Task <PagedList <T> > GetListAsyncForNote(NoteParams noteParams)
        {
            var list = await dbSetObject.ToListAsync();

            var queryableList = list.AsQueryable();

            PagedList <T> returnValues = PagedList <T> .CreateAsync(queryableList, noteParams.PageNumber, noteParams.PageSize);

            //return await PagedList<T>.CreateAsync(queryableList, noteParams.PageNumber, noteParams.PageSize);
            return(returnValues);
        }