Example #1
0
        public async Task <Page <Visit> > Get(PageRequest pageRequest)
        {
            var increasedTake = pageRequest.Take++;
            var visitEntities = await visitRepository.Get(pageRequest.Skip, increasedTake, pageRequest.Query);

            var visits     = visitEntities.Select(v => v.ToModel()).ToArray();
            var hasMore    = visits.Length == increasedTake;
            int?totalCount = null;

            if (pageRequest.Count)
            {
                totalCount = await visitRepository.GetTotalCount();
            }

            return(new Page <Visit>
            {
                Items = visits,
                HasMore = hasMore,
                TotalCount = totalCount
            });
        }