public static async Task <AssetModel> UpsertAssetByExternalIdAsync(this ManagementClient 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); }
/// <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 ManagementClient 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); }