public PaginationSet <WalkSightViewModel> Get(int id, int?page, int?pageSize) { PaginationSet <WalkSightViewModel> pagedSet = null; try { int currentPage = page.Value; int currentPageSize = pageSize.Value; List <WalkSight> _walksights = null; int _totalSights = new int(); Walk _walk = _walkRepository.GetSingle(id); _walksights = _walkSightRepository.AllIncluding(ws => ws.Sight, ws => ws.Walk) .Where(ws => ws.WalkId == id) .OrderBy(ws => ws.Id) .Skip(currentPage * currentPageSize) .Take(currentPageSize) .ToList(); _totalSights = _walk.WalkSights.Count(); IEnumerable <WalkSightViewModel> _sightsVM = Mapper.Map <IEnumerable <WalkSight>, IEnumerable <WalkSightViewModel> >(_walksights); pagedSet = new PaginationSet <WalkSightViewModel>() { Page = currentPage, TotalCount = _totalSights, TotalPages = (int)Math.Ceiling((decimal)_totalSights / currentPageSize), Items = _sightsVM }; } catch (Exception ex) { _loggingRepository.Add(new Error() { Message = ex.Message, StackTrace = ex.StackTrace, CreatedDate = DateTime.Now }); _loggingRepository.Commit(); } return(pagedSet); }