Esempio n. 1
0
        public static async Task <AssetModel> UpsertAssetByExternalIdAsync(this ContentManagementClient client, string externalId, FileContentSource fileContent, IEnumerable <AssetDescription> descriptions)
        {
            if (string.IsNullOrEmpty(externalId))
            {
                throw new ArgumentException("The external id is not specified.", nameof(externalId));
            }

            if (fileContent == null)
            {
                throw new ArgumentNullException(nameof(fileContent));
            }

            if (descriptions == null)
            {
                throw new ArgumentNullException(nameof(descriptions));
            }

            var fileResult = await client.UploadFileAsync(fileContent);

            var asset = new AssetUpsertModel
            {
                FileReference = fileResult,
                Descriptions  = descriptions
            };

            var response = await client.UpsertAssetByExternalIdAsync(externalId, asset);

            return(response);
        }
Esempio n. 2
0
        /// <summary>
        /// Creates asset.
        /// </summary>
        /// <param name="client"></param>
        /// <param name="fileContent">Represents the content of the file.</param>
        /// <param name="assetUpdateModel">Updated values for asset.</param>
        public static async Task <AssetModel> CreateAssetAsync(this ContentManagementClient client, FileContentSource fileContent, AssetUpdateModel assetUpdateModel)
        {
            if (fileContent == null)
            {
                throw new ArgumentNullException(nameof(fileContent));
            }
            if (assetUpdateModel == null)
            {
                throw new ArgumentNullException(nameof(assetUpdateModel));
            }

            if (assetUpdateModel.Descriptions == null)
            {
                throw new ArgumentNullException(nameof(assetUpdateModel.Descriptions));
            }

            var fileResult = await client.UploadFileAsync(fileContent);

            var asset = new AssetUpsertModel
            {
                FileReference = fileResult,
                Descriptions  = assetUpdateModel.Descriptions,
                Title         = assetUpdateModel.Title
            };

            var response = await client.CreateAssetAsync(asset);

            return(response);
        }