Ejemplo n.º 1
0
        public async Task <string> QueryPagedAsync([FromQuery] CouponParam param)
        {
            var filter = param.SearchLambda <Coupon, CouponParam>();
            var result = await _couponRepository.QueryPagedAsync(param.PageNum, param.PageSize, null, filter);

            var dtos = new List <CouponDto>();

            foreach (var coupon in result.Items)
            {
                var productCategoryRelationList = await _couponProductCategoryRelationRepository.QueryAsync(c => c.CouponId == coupon.Id);

                var productRelationList = await _couponProductRelationRepository.QueryAsync(c => c.CouponId == coupon.Id);

                var dto = coupon.EntityMap <Coupon, CouponDto>();
                dto.ProductCategoryRelationList = productCategoryRelationList.ToList();
                dto.ProductRelationList         = productRelationList.ToList();
                dtos.Add(dto);
            }
            var pageData = new PagedDto <CouponDto>
            {
                Code     = 200,
                Msg      = "获取数据成功",
                Total    = result.TotalResults,
                PageSize = param.PageSize,
                Data     = dtos
            };
            var json = pageData.ToString();

            return(json);
        }
        public async Task <PagedDto <Dto, Model> > GetAll <Dto, Model>(int offset, int pageSize) where Dto : IDto <Model> where Model : class, IDbEntity <Model>
        {
            var set   = _context.GetSet <Model>();
            var query = set;

            var totalItems = query.Count();

            var items = await query.OrderBy(x => x.Id)
                        .Skip(offset)
                        .Take(pageSize)
                        .ToListAsync();

            var dtos = items
                       .Select(x => GetDto <Dto, Model>(x))
                       .ToList();

            var pagedDto = new PagedDto <Dto, Model>
            {
                Items      = dtos,
                TotalItems = totalItems,
                Offset     = offset,
                Count      = pageSize
            };

            return(pagedDto);
        }
        public async Task <string> QueryPagedAsync([FromQuery] MenuParam param)
        {
            var result = await _menuRepository.QueryPagedAsync(c => c.ParentId == null, param);

            //var allSubMenu = await _menuRepository.QueryAsync(c => c.ParentId != null);
            var list = new List <MenuDto>();

            if (result.Items != null)
            {
                foreach (var item in result.Items)
                {
                    var menuDto = item.EntityMap <Menu, MenuDto>();
                    menuDto.HasChildren = true;
                    list.Add(menuDto);
                }
            }

            var pageData = new PagedDto <MenuDto>
            {
                Code  = 200,
                Msg   = "获取数据成功",
                Total = result.TotalResults,
                //PageSize = param.P,
                Data = list
            };
            var json = pageData.ToString();

            return(json);
        }
Ejemplo n.º 4
0
        public async Task <string> QueryPagedAsync([FromQuery] SubjectParam param)
        {
            var filter = param.SearchLambda <Subject, SubjectParam>();
            var result = await _subjectRepository.QueryPagedAsync(param.PageNum, param.PageSize, null, filter);

            foreach (var item in result.Items)
            {
                //关联产品数
                var subjectProduct = await _subjectRepository.GetSubjectProductsAsync(item.Id);

                item.ProductCount = subjectProduct.Count();

                //评论数
                var subjectComment = await _subjectCommentRepository.QueryAsync(c => c.SubjectId == item.Id);

                item.CommentCount = subjectComment.Count();
            }

            var pageData = new PagedDto <Subject>
            {
                Code     = 200,
                Msg      = "获取数据成功",
                Total    = result.TotalResults,
                PageSize = param.PageSize,
                Data     = result.Items.ToList()
            };
            var json = pageData.ToString();

            return(json);
        }
Ejemplo n.º 5
0
        public async Task <string> QueryPagedAsync([FromQuery] ProductCategoryParam param)
        {
            try
            {
                var result = await _productCategoryRepository.QueryPagedAsync(c => c.ParentId == null, param);

                var list = new List <ProductCategoryDto>();
                if (result.Items != null)
                {
                    foreach (var item in result.Items)
                    {
                        var menuDto = item.EntityMap <ProductCategory, ProductCategoryDto>();
                        menuDto.HasChildren = true;
                        list.Add(menuDto);
                    }
                }

                var pageData = new PagedDto <ProductCategoryDto>
                {
                    Code  = 200,
                    Msg   = "获取数据成功",
                    Total = result.TotalResults,
                    //PageSize = param.P,
                    Data = list
                };
                var json = pageData.ToString();
                return(json);
            }
            catch (Exception ex)
            {
                throw;
            }
        }
Ejemplo n.º 6
0
        public async Task <string> QueryPagedAsync([FromQuery] UserParam param)
        {
            var filter = param.SearchLambda <User, UserParam>();
            var result = await _userRepository.QueryPagedAsync(param.PageNum, param.PageSize, null, filter);

            var userList = new List <User>();

            foreach (var item in result.Items)
            {
                var userLogins = await _userLoginRepository.QueryAsync(c => c.UserId == item.Id);

                item.LoginTimes = userLogins.Count();
                var userlogin = userLogins.OrderByDescending(c => c.CreateTime).Skip(1).FirstOrDefault();
                if (userlogin == null)
                {
                    continue;
                }
                item.LastLoginTime = userlogin.CreateTime;
                item.LastLoginIp   = userlogin.LoginIp;
            }
            var pageData = new PagedDto <User>
            {
                Code     = 200,
                Msg      = "获取数据成功",
                Total    = result.TotalResults,
                PageSize = param.PageSize,
                Data     = result.Items.ToList()
            };
            var json = pageData.ToString();

            return(json);
        }
Ejemplo n.º 7
0
        public async Task <PagedDto <TeamStadiumDto, TeamStadium> > GetStadiumHistory(int teamId, int offset = 0, int pageSize = 10)
        {
            var query = _context.TeamStadiums
                        .Where(x => x.TeamId == teamId);

            var totalItems = query.Count();

            var items = await query.OrderBy(x => x.FromDate)
                        .Skip(offset)
                        .Take(pageSize)
                        .ToListAsync();

            var dtos = items
                       .Select(x =>
            {
                var dto = new TeamStadiumDto();
                dto.Populate(x);
                return(dto);
            })
                       .ToList();

            var pagedDto = new PagedDto <TeamStadiumDto, TeamStadium>
            {
                Items      = dtos,
                TotalItems = totalItems,
                Offset     = offset,
                Count      = pageSize
            };

            return(pagedDto);
        }
Ejemplo n.º 8
0
        /// <summary>
        /// CYUsers
        /// </summary>
        /// <param name="pageSize"></param>
        /// <param name="pageIndex"></param>
        /// <param name="strSort"></param>
        /// <param name="bAsc"></param>
        /// <returns></returns>
        public PagedDto <CYUsersDto> SelectByPaged(int pageSize, int pageIndex, string strSort, bool bAsc)
        {
            int pageCount             = 0;
            PagedDto <CYUsersDto> dto = new PagedDto <CYUsersDto>();

            dto.Data      = repository.SelectByPaged(null, pageSize, pageIndex, out pageCount, strSort, bAsc).MapToList <CYUsersInfo, CYUsersDto>().ToList();
            dto.PageCount = pageCount;
            return(dto);
        }
Ejemplo n.º 9
0
        public async Task <PagedDto <UserSearchDto> > GetUsersAsync(decimal[]?serviceAreas, string[]?userTypes, string searchText, bool?isActive, int pageSize, int pageNumber, string orderBy, string direction)
        {
            var query = DbSet.AsNoTracking();

            if (serviceAreas != null && serviceAreas.Length > 0)
            {
                query = query.Where(u => u.HmrServiceAreaUsers.Any(s => serviceAreas.Contains(s.ServiceAreaNumber)));
            }

            if (userTypes != null && userTypes.Length > 0)
            {
                query = query.Where(u => userTypes.Contains(u.UserType));
            }

            if (searchText.IsNotEmpty())
            {
                searchText = searchText.Trim();

                query = query
                        .Where(u => u.Username.Contains(searchText) || u.FirstName.Contains(searchText) || (u.FirstName + " " + u.LastName).Contains(searchText) || u.LastName.Contains(searchText) || u.BusinessLegalName.Contains(searchText));
            }

            if (isActive != null)
            {
                query = (bool)isActive
                    ? query.Where(u => u.EndDate == null || u.EndDate > DateTime.Today)
                    : query.Where(u => u.EndDate != null && u.EndDate <= DateTime.Today);
            }

            query = query.Include(u => u.HmrServiceAreaUsers);

            var pagedEntity = await Page <HmrSystemUser, HmrSystemUser>(query, pageSize, pageNumber, orderBy, direction);

            var users = Mapper.Map <IEnumerable <UserSearchDto> >(pagedEntity.SourceList);

            var userServiceArea = pagedEntity.SourceList.SelectMany(u => u.HmrServiceAreaUsers).ToLookup(u => u.SystemUserId);

            foreach (var user in users)
            {
                user.ServiceAreas    = string.Join(",", userServiceArea[user.SystemUserId].Select(x => x.ServiceAreaNumber).OrderBy(x => x));
                user.HasLogInHistory = pagedEntity.SourceList.Any(u => u.SystemUserId == user.SystemUserId && u.UserGuid != null);
            }

            var pagedDTO = new PagedDto <UserSearchDto>
            {
                PageNumber = pageNumber,
                PageSize   = pageSize,
                TotalCount = pagedEntity.TotalCount,
                SourceList = users,
                OrderBy    = orderBy,
                Direction  = direction
            };

            return(pagedDTO);
        }
Ejemplo n.º 10
0
        public async Task <string> QueryPagedAsync([FromQuery] ProductsParam param)
        {
            var filter = param.SearchLambda <Products, ProductsParam>();
            var result = await _productRepository.QueryPagedAsync(param.PageNum, param.PageSize, null, filter);

            var list = new List <ProductDto>();

            foreach (var item in result.Items)
            {
                var dto = item.EntityMap <Products, ProductDto>();
                //
                var memberList = await _productMemberPriceRepository.QueryAsync(c => c.ProductId == item.Id);

                dto.MemberPriceList = memberList.Select(c => c.EntityMap <ProductMemberPrice, ProductMemberPriceDto>()).ToList();

                //
                var fullReductionList = await _productFullReductionRepository.QueryAsync(c => c.ProductId == item.Id);

                dto.ProductFullReductionList = fullReductionList.Select(c => c.EntityMap <ProductFullReduction, ProductFullReductionDto>()).ToList();

                //
                var ladderList = await _productLadderRepository.QueryAsync(c => c.ProductId == item.Id);

                dto.ProductLadderList = ladderList.Select(c => c.EntityMap <ProductLadder, ProductLadderDto>()).ToList();

                //
                var attributeValueList = await _productAttributeValueRepository.QueryAsync(c => c.ProductId == item.Id);

                dto.ProductAttributeValueList = attributeValueList.Select(c => c.EntityMap <ProductAttributeValue, ProductAttributeValueDto>()).ToList();

                //
                var skuStockList = await _productSkuStockRepository.QueryAsync(c => c.ProductId == item.Id);

                dto.SkuStockList = skuStockList.Select(c => c.EntityMap <ProductSkuStock, ProductSkuStockDto>()).ToList();

                list.Add(dto);
            }
            var pageData = new PagedDto <ProductDto>
            {
                Code     = 200,
                Msg      = "获取数据成功",
                Total    = result.TotalResults,
                PageSize = param.PageSize,
                Data     = list
            };
            var json = pageData.ToString();

            return(json);
        }
Ejemplo n.º 11
0
        public async Task <PagedDto <ActivityCodeSearchDto> > GetActivityCodesAsync(string[]?maintenanceTypes, decimal[]?locationCodes, bool?isActive, string searchText, int pageSize, int pageNumber, string orderBy, string direction)
        {
            var query = DbSet.AsNoTracking();

            if (maintenanceTypes != null && maintenanceTypes.Length > 0)
            {
                query = query.Where(ac => maintenanceTypes.Contains(ac.MaintenanceType));
            }

            if (locationCodes != null && locationCodes.Length > 0)
            {
                query = query.Where(ac => locationCodes.Contains(ac.LocationCodeId));
            }

            if (isActive != null)
            {
                query = (bool)isActive
                    ? query.Where(ac => ac.EndDate == null || ac.EndDate > DateTime.Today)
                    : query.Where(ac => ac.EndDate != null && ac.EndDate <= DateTime.Today);
            }

            if (searchText.IsNotEmpty())
            {
                query = query
                        .Where(ac => ac.ActivityName.Contains(searchText) || ac.ActivityNumber.Contains(searchText));
            }

            var pagedEntity = await Page <HmrActivityCode, HmrActivityCode>(query, pageSize, pageNumber, orderBy, direction);

            var activityCodes = Mapper.Map <IEnumerable <ActivityCodeSearchDto> >(pagedEntity.SourceList);

            // Find out which activity numbers are being used
            await foreach (var activityNumber in FindActivityNumbersInUseAync(activityCodes.Select(ac => ac.ActivityNumber)))
            {
                activityCodes.FirstOrDefault(ac => ac.ActivityNumber == activityNumber).IsReferenced = true;
            }

            var pagedDTO = new PagedDto <ActivityCodeSearchDto>
            {
                PageNumber = pageNumber,
                PageSize   = pageSize,
                TotalCount = pagedEntity.TotalCount,
                SourceList = activityCodes,
                OrderBy    = orderBy,
                Direction  = direction
            };

            return(pagedDTO);
        }
Ejemplo n.º 12
0
        public PagedDto <CadastroAuditoria> BuscarAgenciaUsuarioEvent(Guid id)
        {
            var sql = @"SELECT TOP 10 Id,UsuarioId, UserName, DataOcorrencia, Login, Permissao, Menssagem FROM  CadastroAuditoria " +
                      "WHERE UsuarioId = @sid " +
                      "ORDER By DataOcorrencia DESC ";

            var result = cn.Query <CadastroAuditoria>(sql, new { sid = id });

            var pagedList = new PagedDto <CadastroAuditoria>()
            {
                List = result
            };

            return(pagedList);
        }
        public static async Task <PagedDto <TDest> > GetPagedResultOf <TSource, TDest>(this IQueryable <TSource> query, GetPagedItemsDto paginationSettings, IMapper mapper, CancellationToken cancellationToken)
        {
            var result = new PagedDto <TDest>()
            {
                Page       = paginationSettings.Page,
                PageSize   = paginationSettings.PageSize,
                TotalItems = await query.CountAsync(cancellationToken)
            };

            var skip        = (result.Page - 1) * result.PageSize;
            var itemsOfPage = await query.Skip(skip).Take(result.PageSize).ToListAsync(cancellationToken);

            result.Items = mapper.Map <List <TDest> >(itemsOfPage);

            return(result);
        }
        public async Task <string> QueryPagedAsync([FromQuery] HomeRecommendProductParam param)
        {
            var filter = param.SearchLambda <HomeRecommendProduct, HomeRecommendProductParam>();
            var result = await _homeRecommendProductRepository.QueryPagedAsync(param.PageNum, param.PageSize, null, filter);

            var pageData = new PagedDto <HomeRecommendProduct>
            {
                Code     = 200,
                Msg      = "获取数据成功",
                Total    = result.TotalResults,
                PageSize = param.PageSize,
                Data     = result.Items.ToList()
            };
            var json = pageData.ToString();

            return(json);
        }
Ejemplo n.º 15
0
        public async Task <string> QueryPagedAsync([FromQuery] MemberStatisticsInfoParam param)
        {
            var filter = param.SearchLambda <MemberStatisticsInfo, MemberStatisticsInfoParam>();
            var result = await _memberStatisticsInfoRepository.QueryPagedAsync(param.PageNum, param.PageSize, null, filter);

            var pageData = new PagedDto <MemberStatisticsInfo>
            {
                Code     = 200,
                Msg      = "获取数据成功",
                Total    = result.TotalResults,
                PageSize = param.PageSize,
                Data     = result.Items.ToList()
            };
            var json = pageData.ToString();

            return(json);
        }
Ejemplo n.º 16
0
        public async Task <string> QueryPagedAsync([FromQuery] FlashPromotionSessionParam param)
        {
            var filter = param.SearchLambda <FlashPromotionSession, FlashPromotionSessionParam>();
            var result = await _flashPromotionSessionRepository.QueryPagedAsync(param.PageNum, param.PageSize, null, filter);

            var pageData = new PagedDto <FlashPromotionSession>
            {
                Code     = 200,
                Msg      = "获取数据成功",
                Total    = result.TotalResults,
                PageSize = param.PageSize,
                Data     = result.Items.ToList()
            };
            var json = pageData.ToString();

            return(json);
        }
        public async Task <string> QueryPagedAsync([FromQuery] IntegrationConsumeSettingParam param)
        {
            var filter = param.SearchLambda <IntegrationConsumeSetting, IntegrationConsumeSettingParam>();
            var result = await _integrationConsumeSettingRepository.QueryPagedAsync(param.PageNum, param.PageSize, null, filter);

            var pageData = new PagedDto <IntegrationConsumeSetting>
            {
                Code     = 200,
                Msg      = "获取数据成功",
                Total    = result.TotalResults,
                PageSize = param.PageSize,
                Data     = result.Items.ToList()
            };
            var json = pageData.ToString();

            return(json);
        }
Ejemplo n.º 18
0
        public async Task <string> QueryPagedAsync([FromQuery] PrefrenceAreaParam param)
        {
            var filter = param.SearchLambda <PrefrenceArea, PrefrenceAreaParam>();
            var result = await _prefrenceAreaRepository.QueryPagedAsync(param.PageNum, param.PageSize, null, filter);

            var pageData = new PagedDto <PrefrenceArea>
            {
                Code     = 200,
                Msg      = "获取数据成功",
                Total    = result.TotalResults,
                PageSize = param.PageSize,
                Data     = result.Items.ToList()
            };
            var json = pageData.ToString();

            return(json);
        }
        public async Task <string> QueryPagedAsync(Guid id, [FromQuery] ProductAttributeParam param)
        {
            param.ProductAttributeCategoryId = id;
            var filter = param.SearchLambda <ProductAttribute, ProductAttributeParam>();
            var result = await _productAttributeRepository.QueryPagedAsync(param.PageNum, param.PageSize, null, filter);

            var pageData = new PagedDto <ProductAttribute>
            {
                Code     = 200,
                Msg      = "获取数据成功",
                Total    = result.TotalResults,
                PageSize = param.PageSize,
                Data     = result.Items.ToList()
            };
            var json = pageData.ToString();

            return(json);
        }
Ejemplo n.º 20
0
        public async Task <PagedDto <TOutput> > Page <TInput, TOutput>(IQueryable <TInput> list, int pageSize, int pageNumber, string orderBy, string direction = "")
        {
            var totalRecords = list.Count();

            if (pageNumber <= 0)
            {
                pageNumber = 1;
            }

            var pagedList = list.DynamicOrderBy($"{orderBy} {direction}") as IQueryable <TInput>;

            if (pageSize > 0)
            {
                var skipRecordCount = (pageNumber - 1) * pageSize;
                pagedList = pagedList.Skip(skipRecordCount)
                            .Take(pageSize);
            }

            var result = await pagedList.ToListAsync();

            IEnumerable <TOutput> outputList;

            if (typeof(TOutput) != typeof(TInput))
            {
                outputList = Mapper.Map <IEnumerable <TInput>, IEnumerable <TOutput> >(result);
            }
            else
            {
                outputList = (IEnumerable <TOutput>)result;
            }

            var pagedDTO = new PagedDto <TOutput>
            {
                PageNumber = pageNumber,
                PageSize   = pageSize,
                TotalCount = totalRecords,
                SourceList = outputList,
                OrderBy    = orderBy,
                Direction  = direction
            };

            return(pagedDTO);
        }
Ejemplo n.º 21
0
        public async Task <string> QueryPagedAsync([FromQuery] MemberParam param)
        {
            var filter = param.SearchLambda <Member, MemberParam>();
            var result = await _memberRepository.QueryPagedAsync(param.PageNum, param.PageSize, null, filter);

            //var list = new List<MemberDto>();
            var list     = result.Items.Select(c => c.EntityMap <Member, MemberDto>()).ToList();
            var pageData = new PagedDto <MemberDto>
            {
                Code     = 200,
                Msg      = "获取数据成功",
                Total    = result.TotalResults,
                PageSize = param.PageSize,
                Data     = list
            };
            var json = pageData.ToString();

            return(json);
        }
Ejemplo n.º 22
0
        public async Task <PagedDto <RoleSearchDto> > GetRolesAync(string searchText, bool?isActive, int pageSize, int pageNumber, string orderBy, string direction)
        {
            var query = DbSet.AsNoTracking();

            if (searchText.IsNotEmpty())
            {
                searchText = searchText.Trim();

                query = query
                        .Where(x => x.Name.Contains(searchText) || x.Description.Contains(searchText));
            }

            if (isActive != null)
            {
                query = (bool)isActive
                    ? query.Where(x => x.EndDate == null || x.EndDate > DateTime.Today)
                    : query.Where(x => x.EndDate != null && x.EndDate <= DateTime.Today);
            }

            var pagedEntity = await Page <HmrRole, HmrRole>(query, pageSize, pageNumber, orderBy, direction);

            var roles = Mapper.Map <IEnumerable <RoleSearchDto> >(pagedEntity.SourceList);

            // Find out which roles are in use
            await foreach (var roleId in FindRolesInUseAync(roles.Select(x => x.RoleId)))
            {
                roles.FirstOrDefault(x => x.RoleId == roleId).IsReferenced = true;
            }

            var pagedDTO = new PagedDto <RoleSearchDto>
            {
                PageNumber = pageNumber,
                PageSize   = pageSize,
                TotalCount = pagedEntity.TotalCount,
                SourceList = roles,
                OrderBy    = orderBy,
                Direction  = direction
            };

            return(pagedDTO);
        }
        public async Task <PagedDto <CompanyProfile> > SearchByCompaniesHouseNumber(string number)
        {
            var result = await GetCompaniesHouseClient().GetCompanyProfileAsync(number);

            if (result != null && result.Data != null)
            {
                var a = result.Data.RegisteredOfficeAddress;
                return(PagedDto <CompanyProfile> .One(new CompanyProfile
                {
                    Name = result.Data.CompanyName,
                    Address = new CompanyAddress {
                        Line1 = a.AddressLine1, Line2 = a.AddressLine2, CityOrTown = a.Locality, PostCode = a.PostalCode
                    },
                    IncorporationDate = result.Data.DateOfCreation,
                    Number = result.Data.CompanyNumber
                }));
            }
            else
            {
                return(PagedDto <CompanyProfile> .Empty);
            }
        }
Ejemplo n.º 24
0
        public ActionResult GetDogs(
            ApiVersion apiVersion,
            [FromQuery] int page    = 1,
            [FromQuery] int perPage = 10)
        {
            perPage = Math.Max(perPage, 1);
            page    = Math.Max(page, 1);

            var data =
                _entityManager.GetAllDogs()
                .Skip((page - 1) * perPage)
                .Take(perPage)
                .Select(dog => _dogMapper.ConvertToDto(dog, Url, apiVersion));

            var paginationData = new PageDataDto(
                page,
                data.Count(),
                perPage,
                _entityManager.GetDogCount());

            PagedDto <DogDto> result = new PagedDto <DogDto>(paginationData, data);

            return(Ok(result.WithLinks <DogDto>(Url, apiVersion, nameof(GetDogs))));
        }
Ejemplo n.º 25
0
        public IActionResult GetComments(long postId, PagedDto dto)
        {
            var result = this.commentFilterService.GetCommentsForPost(postId, dto.PageNumber, dto.PageSize);

            return(this.apiResultService.Ok(result));
        }
Ejemplo n.º 26
0
        public IActionResult FilterComments(long postId, PagedDto pagedDto)
        {
            var comments = this.commentFilterService.GetCommentsForPost(postId, pagedDto.PageNumber, pagedDto.PageSize);

            return(this.apiResultService.Ok(comments));
        }
Ejemplo n.º 27
0
        public static PagedDto <T> WithLinks <T>(
            this PagedDto <T> dto,
            IUrlHelper urlHelper,
            ApiVersion apiVersion,
            string routeName)
        {
            IList <LinkDto> links = new List <LinkDto>
            {
                new LinkDto(
                    urlHelper?.Link(
                        routeName,
                        new {
                    page    = dto.Page.Number,
                    perPage = dto.Page.PerPage,
                    version = apiVersion.ToString()
                }),
                    "self",
                    System.Net.Http.HttpMethod.Get.Method),
                new LinkDto(
                    urlHelper?.Link(
                        routeName,
                        new {
                    page    = 1,
                    perPage = dto.Page.PerPage,
                    version = apiVersion.ToString()
                }),
                    "first",
                    System.Net.Http.HttpMethod.Get.Method)
            };

            if (dto.Page.Number > 1)
            {
                links.Add(new LinkDto(
                              urlHelper?.Link(
                                  routeName,
                                  new
                {
                    page    = dto.Page.Number - 1,
                    perPage = dto.Page.PerPage,
                    version = apiVersion.ToString()
                }),
                              "prev",
                              System.Net.Http.HttpMethod.Get.Method));
            }

            if (dto.Page.Number < dto.Page.TotalPages)
            {
                links.Add(new LinkDto(
                              urlHelper?.Link(
                                  routeName,
                                  new
                {
                    page    = dto.Page.Number + 1,
                    perPage = dto.Page.PerPage,
                    version = apiVersion.ToString()
                }),
                              "next",
                              System.Net.Http.HttpMethod.Get.Method));
            }

            links.Add(new LinkDto(
                          urlHelper?.Link(
                              routeName,
                              new
            {
                page    = dto.Page.TotalPages,
                perPage = dto.Page.PerPage,
                version = apiVersion.ToString()
            }),
                          "last",
                          System.Net.Http.HttpMethod.Get.Method));

            dto.Links = links;

            return(dto);
        }