示例#1
0
        public async Task <MemberListResponse> ListAsync(int pageNum = 1, int pageSize = 50)
        {
            if (pageNum < 1 || pageSize < 1)
            {
                return(new MemberListResponse(400, "Wrong pagination", "Pagination",
                                              "The pageNum and pageSize params must be greater than zero."));
            }

            int totalRecords = await _memberRepository.CountAsync();

            var items = await _memberRepository.ListAsync(pageNum, pageSize);

            var resources    = _mapper.Map <IEnumerable <Member>, IEnumerable <MemberResource> >(items);
            var resourceList = new MemberListResource(resources, pageNum, pageSize, totalRecords);

            return(new MemberListResponse(resourceList));
        }