IWsCommonGetPurchasedCustomProducts Method |
Namespace: Aruba.Cloud.WsCommon
[OperationContractAttribute] WsResult<CustomProductsData> GetPurchasedCustomProducts()
/// IWsCommon.GetPurchasedCustomProducts Method (c# .NET) public static string GetPurchasedCustomProducts(WsCommonClient client) { //specify the account login details client.ClientCredentials.UserName.UserName = "ARU-0000"; client.ClientCredentials.UserName.Password = "0123456789"; StringBuilder stringBuilder = new StringBuilder(); try { // call method GetPurchasedCustomProducts // obtaining a WsResultOfCustomProductsData item WsResultOfCustomProductsData result = client.GetPurchasedCustomProducts(); // if the call is Success print returned values if (result.Success) { stringBuilder.Append("Operation ends successfully\n"); // get Value returned from server CustomProductsData items = result.Value; if (items.CustomProducts != null) { // category id for monitoring products int monitoringCategory = 4; // query for the productId var query = from CustomProduct product in items.CustomProducts where product.ProductCategory.CustomProductCategoryID == monitoringCategory select product; // for each item print the information foreach (CustomProduct item in query) { stringBuilder.Append("\nProductID: "); stringBuilder.Append(item.ProductID); stringBuilder.Append("\nCustomProductID: "); stringBuilder.Append(item.CustomProductID); stringBuilder.Append("\nName: "); stringBuilder.Append(item.ProductName); stringBuilder.Append("\nQuantity: "); stringBuilder.Append(item.Quantity); stringBuilder.Append("\nDescription: "); stringBuilder.Append(item.ProductDescription); stringBuilder.Append("\ncategory id: "); stringBuilder.Append(item.ProductCategory.CustomProductCategoryID); stringBuilder.Append("\ncategory description: "); stringBuilder.Append(item.ProductCategory.Description); } } } else { throw new ApplicationException(result.ResultMessage); } } catch (Exception ex) { // re-run the error throw new ApplicationException(ex.Message); } return stringBuilder.ToString(); }