public Product(ReferenceName productReference, List <InformationData> informationData, List <Occasion> occasions, List <ImageData> images) { this.Reference = productReference; this.InformationData = informationData; this.Occasions = occasions; this.Images = images; }
/// <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> /// Creates a supplier in the Cbis system with the specified information. /// </summary> /// <param name="name">The name of the organization.</param> /// <param name="referenceName">A name reference that the organization is known by in your system.</param> /// <param name="uiCulture">The UI culture.</param> /// <param name="languageCulture">The language culture.</param> /// <returns>An id which the organization is know by in the Cbis</returns> /// <exception cref="System.ArgumentNullException"> /// name /// or /// referenceName /// </exception> /// <exception cref="System.ArgumentOutOfRangeException"> /// uiCulture;May not be of Invariant type /// or /// languageCulture;May not be of Invariant type /// </exception> public ReferenceName CreateSupplier(string name, ReferenceName referenceName, CultureInfo uiCulture, CultureInfo languageCulture) { if (string.IsNullOrEmpty(name)) { throw new ArgumentNullException("name"); } if (referenceName == null) { throw new ArgumentNullException("referenceName"); } if (CultureInfo.InvariantCulture.Equals(uiCulture)) { throw new ArgumentOutOfRangeException("uiCulture", "May not be of Invariant type"); } if (CultureInfo.InvariantCulture.Equals(languageCulture)) { throw new ArgumentOutOfRangeException("languageCulture", "May not be of Invariant type"); } var orgReference = _client.CreateOrganization(name, new OrganizationReference(referenceName), uiCulture.Name, languageCulture.Name); return(new ReferenceName(orgReference.SubSystem, orgReference.LocalName)); }
public Product(ReferenceName productReference, List<InformationData> informationData, List<Occasion> occasions, List<ImageData> images) { this.Reference = productReference; this.InformationData = informationData; this.Occasions = occasions; this.Images = images; }
private static void AddReference(CbisSupplierManagementClient client, List<string> list) { if (list.Count != 2) { Console.WriteLine(string.Format("Usage: {0} [username] [password] addref [subsystem:id (existing ref)] [subsystem:id (ref to add)]", Path.GetFileName(System.Reflection.Assembly.GetEntryAssembly().Location))); return; } ReferenceName target = new ReferenceName(list[0]); ReferenceName newName = new ReferenceName(list[1]); client.ModifyProductReferences( null, target, new List<ReferenceName>() { newName }, new List<ReferenceName>()); }
public int CompareTo(object obj) { if (obj == null) { throw new ArgumentNullException("obj"); } ReferenceName name = obj as ReferenceName; if (name == null) { throw new ArgumentOutOfRangeException("obj", obj, "Can only be compared to ReferenceName"); } int ret = SubSystem.CompareTo(name.SubSystem); return(ret != 0 ? ret : LocalName.CompareTo(name.SubSystem)); }
/// <summary> /// Updates information about the supplier. Data normally used is contact information, like email, phone and address. /// </summary> /// <param name="organizationReference">The organization reference.</param> /// <param name="informationData">The information data that should be stored with the supplier.</param> /// <exception cref="System.ArgumentNullException"> /// organizationReference /// or /// informationData /// </exception> public void UpdateSupplier(ReferenceName organizationReference, List <InformationData> informationData) { if (organizationReference == null) { throw new ArgumentNullException("organizationReference"); } if (informationData == null) { throw new ArgumentNullException("informationData"); } var orgRef = new OrganizationReference(organizationReference); var unifiedItems = this.InformationDataValidator(informationData); var dataList = unifiedItems.Select(x => x.Create()).ToArray(); _client.UpdateOrganization(orgRef, dataList); }
/// <summary> /// Retrieves all products from the organization in a paged manner. /// </summary> /// <param name="organizationReference">The organization reference.</param> /// <param name="pageSize">Size of the page.</param> /// <param name="skipPages">The skip pages.</param> /// <returns></returns> /// <exception cref="System.ArgumentNullException">The organizationReference was null</exception> public List <ProductReference> GetProducts(ReferenceName organizationReference, int pageSize, int skipPages) { OrganizationReference orgRef = null; if (organizationReference != null) { orgRef = new OrganizationReference(organizationReference); } var productList = _client.GetProducts(orgRef, pageSize, skipPages); var list = new List <ProductReference>(); foreach (var p in productList) { list.Add(new ProductReference(p.SystemName, p.ReferenceNames.Select(x => new ReferenceName(x.SubSystem, x.LocalName)))); } return(list); }
/// <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)); }
public ProductReferenceSetResult ModifyProductReferences( OrganizationReference organizationReference, ReferenceName productToActOn, List <ReferenceName> referencesToAdd, List <ReferenceName> referencesToRemove) { if (referencesToAdd == null) { referencesToAdd = new List <ReferenceName>(); } if (referencesToRemove == null) { referencesToRemove = new List <ReferenceName>(); } if (productToActOn == null) { throw new ArgumentNullException("productToActOn"); } if (referencesToAdd.Count == 0 && referencesToRemove.Count == 0) { throw new InvalidOperationException("No names addad and no removed, call obsolete. Remove"); } var result = _client.ModifyProductReferences( organizationReference, productToActOn.CreateContractReferenceName(), referencesToAdd.Select(x => x.CreateContractReferenceName()).ToArray(), referencesToRemove.Select(x => x.CreateContractReferenceName()).ToArray()); return (new ProductReferenceSetResult( result.AddedReferences.Select(x => new ReferenceName(x.SubSystem, x.LocalName)), result.RemovedReferences.Select(x => new ReferenceName(x.SubSystem, x.LocalName)))); }
/// <summary> /// Gets the product references that are available for a specific product. /// </summary> /// <param name="organizationReference">The organization reference.</param> /// <param name="productReference">The product reference.</param> /// <returns></returns> /// <exception cref="System.ArgumentNullException">The productReference was null</exception> public ProductReference GetProductReferences(OrganizationReference organizationReference, ReferenceName productReference) { if (productReference == null) { throw new ArgumentNullException("productReference"); } var refs = _client.GetProductReferences( organizationReference != null ? new Generated.OrganizationReference(new ReferenceName(organizationReference.ToString())) : null, new Generated.ReferenceName(productReference)); return(new ProductReference(refs.SystemName, refs.ReferenceNames.Select(x => new ReferenceName(x.SubSystem, x.LocalName)))); }
private static void SetCategory(CbisSupplierManagementClient client, List<string> list) { if (list.Count != 3) { Console.WriteLine( string.Format( "Usage: {0} [username] [password] setcat [orgreference] [product reference] [categoryId]", Path.GetFileName(System.Reflection.Assembly.GetEntryAssembly().Location))); return; } ReferenceName orgRef = new ReferenceName(list[0]); ReferenceName prodRef = new ReferenceName(list[1]); int categoryId = int.Parse(list[2]); var product = client.GetProduct(orgRef, prodRef); client.SetProduct( orgRef, ((Client.InformationDataString)product.InformationData.First(x => x.AttributeId == 99)).Value, categoryId, prodRef, product.InformationData, product.Images, product.Occasions); }
/// <summary> /// Determines whether the specified <see cref="System.Object" />, is equal to this instance. /// </summary> /// <param name="obj">The <see cref="System.Object" /> to compare with this instance.</param> /// <returns> /// <c>true</c> if the specified <see cref="System.Object" /> is equal to this instance; otherwise, <c>false</c>. /// </returns> public override bool Equals(object obj) { ReferenceName name = obj as ReferenceName; return(name != null && name.SubSystem.Equals(SubSystem) && name.LocalName.Equals(LocalName)); }