Exemple #1
0
        public static AssetsDto FromAssets(IResultList <IEnrichedAssetEntity> assets, Resources resources)
        {
            var response = new AssetsDto
            {
                Total = assets.Total,
                Items = assets.Select(x => AssetDto.FromAsset(x, resources)).ToArray()
            };

            return(CreateLinks(response, resources));
        }
Exemple #2
0
        public static AssetsDto FromAssets(IResultList <IEnrichedAssetEntity> assets, ApiController controller, string app)
        {
            var response = new AssetsDto
            {
                Total = assets.Total,
                Items = assets.Select(x => AssetDto.FromAsset(x, controller, app)).ToArray()
            };

            return(CreateLinks(response, controller, app));
        }
Exemple #3
0
        private static AssetsDto CreateLinks(AssetsDto response, Resources resources)
        {
            var values = new { app = resources.App };

            response.AddSelfLink(resources.Url <AssetsController>(x => nameof(x.GetAssets), values));

            if (resources.CanCreateAsset)
            {
                response.AddPostLink("create", resources.Url <AssetsController>(x => nameof(x.PostAsset), values));
            }

            response.AddGetLink("tags", resources.Url <AssetsController>(x => nameof(x.GetTags), values));

            return(response);
        }
Exemple #4
0
        private static AssetsDto CreateLinks(AssetsDto response, ApiController controller, string app)
        {
            var values = new { app };

            response.AddSelfLink(controller.Url <AssetsController>(x => nameof(x.GetAssets), values));

            if (controller.HasPermission(Permissions.AppAssetsCreate))
            {
                response.AddPostLink("create", controller.Url <AssetsController>(x => nameof(x.PostAsset), values));
            }

            response.AddGetLink("tags", controller.Url <AssetsController>(x => nameof(x.GetTags), values));

            return(response);
        }