/// <summary> /// Archive a product /// </summary> /// <param name="organizationReference">The organization reference.</param> /// <param name="productReference">The product reference.</param> /// <returns>List of CultureInfos</returns> public void ActiveProduct(ReferenceName organizationReference, ReferenceName productReference) { var orgRef = new OrganizationReference(organizationReference); var prodRef = new Generated.ReferenceName(productReference); _client.ActiveProduct(orgRef, prodRef); }
/// <summary> /// Sets information that should be stored with the product. All information submitted though <paramref name="informationData"/> will be stored. /// All informationdata that exists on the product not included in that set will be deleted. /// </summary> /// <param name="organizationReference">The organization reference.</param> /// <param name="name">The name.</param> /// <param name="categoryId">The category identifier.</param> /// <param name="productId">The product identifier.</param> /// <param name="informationData">The information data.</param> /// <param name="images">The images.</param> /// <param name="occasions">The occasions.</param> /// <returns></returns> /// <exception cref="System.ArgumentNullException"> /// organizationReference /// or /// name /// or /// productId /// </exception> public ReferenceName SetProduct(ReferenceName organizationReference, string name, int categoryId, ReferenceName productId, IEnumerable <InformationData> informationData, IEnumerable <ImageData> images, IEnumerable <Occasion> occasions) { if (organizationReference == null) { throw new ArgumentNullException("organizationReference"); } if (name == null) { throw new ArgumentNullException("name"); } if (productId == null) { throw new ArgumentNullException("productId"); } HashSet <InformationData> unifiedItems = InformationDataValidator(informationData); OrganizationReference orgRef = new OrganizationReference(organizationReference); Generated.ReferenceName prodRef = new Generated.ReferenceName(productId); if (occasions == null) { occasions = new List <Occasion>(); } if (images == null) { images = new List <ImageData>(); } ProductCallbackReference productResult = _client.SetProduct(orgRef, name, categoryId, prodRef, unifiedItems.Select(x => x.Create()).ToArray(), images.Select(x => x.Create()).ToArray(), occasions.Select(x => x.Create()).ToArray()); return(new ReferenceName(productResult.CbisProductId.SubSystem, productResult.CbisProductId.LocalName)); }
/// <summary> /// Gets information related to a product. /// </summary> /// <param name="organizationReference">The organization reference.</param> /// <param name="productReference">The product reference.</param> /// <returns></returns> /// <exception cref="System.Exception"></exception> public Product GetProduct(ReferenceName organizationReference, ReferenceName productReference) { var orgRef = new OrganizationReference(organizationReference); var prodRef = new Generated.ReferenceName(productReference); var converter = this.GetInformationDataConverter(); var product = _client.GetProduct(orgRef, prodRef); var productReferenceName = new ReferenceName(product.Reference.SubSystem, product.Reference.LocalName); var informationDataList = new List <InformationData>(); foreach (var data in product.InformationData) { Func <Generated.InformationData, InformationData> dataConverter; if (!converter.TryGetValue(data.GetType(), out dataConverter)) { throw new Exception("Failed to find converter for type: " + data.GetType()); } informationDataList.Add(dataConverter(data)); } var occasions = new List <Occasion>(); foreach (var occasion in product.OccasionData) { occasions.Add(ConvertOccasion(occasion)); } var images = new List <ImageData>(); foreach (var media in product.MediaData) { images.Add(ConvertMedia(media)); } return(new Product(productReferenceName, informationDataList, occasions, images)); }