protected override async Task PatchStubAsync(MaterialStub advMaterialStub, Amsv1MaterialData amsv1Data) { // logo var logoElement = advMaterialStub.GetElementByType(MaterialElementType.CompositeBitmapImage); string uploadUrl = logoElement.UploadUrl; var materialId = advMaterialStub.Id; string fileName = $"{amsv1Data.ImageName}.{amsv1Data.ImageExt}"; var uploadHash = await _okapiClient.UploadFileAsync(materialId, new Uri(uploadUrl), fileName, amsv1Data.ImageData); logoElement.Value.Raw = uploadHash.Raw; // crop area logoElement.Value.CropArea = CropAreaFactory.Create(amsv1Data); // background color var bgColorElement = advMaterialStub.GetElementByType(MaterialElementType.Color); bgColorElement.Value.Raw = amsv1Data.BackgroundColor; // custom images var customImages = new List <SizeSpecificImage>(); foreach (var c in amsv1Data.SizeSpecificImages) { var img = await CreateCustomImageAsync(materialId, new Uri(uploadUrl), c); customImages.Add(img); } logoElement.Value.SizeSpecificImages = customImages.ToArray(); advMaterialStub.Properties.Name = "logo_zmk"; }
protected override async Task PatchStubAsync(MaterialStub advMaterialStub, Amsv1MaterialData amsv1Data) { // original logo var logoElement = advMaterialStub.GetElementByType(MaterialElementType.CompositeBitmapImage); string uploadUrl = logoElement.UploadUrl; var materialId = advMaterialStub.Id; string fileName = $"{amsv1Data.ImageName}.{amsv1Data.ImageExt}"; var uploadHash = await _okapiClient.UploadFileAsync(materialId, new Uri(uploadUrl), fileName, amsv1Data.ImageData); logoElement.Value.Raw = uploadHash.Raw; // crop area logoElement.Value.CropArea = CropAreaFactory.Create(amsv1Data); // background color var bgColorElement = advMaterialStub.GetElementByType(MaterialElementType.Color); bgColorElement.Value.Raw = amsv1Data.BackgroundColor; advMaterialStub.Properties.Name = "logo_kb"; }