コード例 #1
0
        private Pagination <UserDTO> GetPaginatedUsersDtos(int pageNumber, ICollection <User> users)
        {
            ICollection <UserDTO> mapUsersToDto = PaginationMappers.ForUsers(users);

            return(new Pagination <UserDTO>
            {
                TotalNumberOfItems = _userRepository.TotalNumberOfItems,
                TotalNumberOfPages = _userRepository.TotalNumberOfPages,
                Items = mapUsersToDto,
                ItemsPerPage = _userRepository.perPage,
                CurrentPage = pageNumber
            });
        }
コード例 #2
0
        public async Task <Response <ComplaintsDTO> > GetComplaintById(string complaintId)
        {
            Response <ComplaintsDTO> response = new Response <ComplaintsDTO>();
            var complaint = await _complaintsRepo.GetComplaintById(complaintId);

            if (complaint == null)
            {
                response.Message = "Complaint Id not found";
                return(response);
            }

            response.Success = true;
            response.Message = "Complaint";
            response.Data    = PaginationMappers.ForComplaints(complaint);
            return(response);
        }
コード例 #3
0
        public async Task <Response <Pagination <PaginatedComplaintsDTO> > > GetComplaintsByPage(int pageNumber, string categoryId)
        {
            Response <Pagination <PaginatedComplaintsDTO> > response = new Response <Pagination <PaginatedComplaintsDTO> >();
            var complaints = await _complaintsRepo.GetComplaintsByPageNumber(pageNumber, PerPage, categoryId);

            if (complaints != null)
            {
                response.Success = true;
                response.Message = "Complaints paginated";
                response.Data    = new Pagination <PaginatedComplaintsDTO>
                {
                    TotalNumberOfItems = _complaintsRepo.TotalNumberOfItems,
                    TotalNumberOfPages = _complaintsRepo.TotalNumberOfPages,
                    CurrentPage        = pageNumber,
                    ItemsPerPage       = PerPage,
                    Items = PaginationMappers.ForPaginatedComplaints(complaints)
                };
                return(response);
            }
            response.Message = "Something went wrong";
            return(response);
        }
コード例 #4
0
        public async Task <Response <Pagination <ReturnedFeedDTO> > > GetFeedByPages(int pageNumber)
        {
            Response <Pagination <ReturnedFeedDTO> > response = new Response <Pagination <ReturnedFeedDTO> >();
            var feeds = await _feedRepo.GetCategoriesByPageNumber(pageNumber, PerPage);

            if (feeds != null)
            {
                response.Success = true;
                response.Message = "Feeds";
                response.Data    = new Pagination <ReturnedFeedDTO>
                {
                    TotalNumberOfItems = _feedRepo.TotalNumberOfItems,
                    TotalNumberOfPages = _feedRepo.TotalNumberOfPages,
                    CurrentPage        = pageNumber,
                    ItemsPerPage       = PerPage,
                    Items = PaginationMappers.ForCategory(feeds)
                };
                return(response);
            }
            response.Success = false;
            response.Message = "Could not feed by page number";
            return(response);
        }