/// <summary> /// Check whether all Grouped/Configurable products'/Kits' children are valid. /// </summary> /// <param name="inventoryItem">Grouped/Configurable Product/Kit that should be checked</param> /// <returns>Validation result</returns> private bool ValidateChildren(InventoryItem inventoryItem) { List <int> validIds = InputList.Select(validItem => validItem.InventoryID.GetValueOrDefault()).ToList(); List <int> childIds = new List <int>(); bool result = false; InventoryItemPCExt itemPCExt = inventoryItem.GetExtension <InventoryItemPCExt>(); if (itemPCExt != null) { if (itemPCExt.UsrKNCompositeType == KCConstants.GroupedProduct) { IEnumerable <KNSIGroupedItems> childItems = Graph.GroupedItemChilds.Select(inventoryItem.InventoryID).RowCast <KNSIGroupedItems>(); childIds.AddRange(childItems.Select(child => child.MappedInventoryID.GetValueOrDefault())); } else if (itemPCExt.UsrKNCompositeType == KCConstants.ConfigurableProduct) { IEnumerable <InventoryItem> childItems = Graph.ChildrenByCompositeId.Select(inventoryItem.InventoryID).RowCast <InventoryItem>(); childIds.AddRange(childItems.Select(child => child.InventoryID.GetValueOrDefault())); } } if (inventoryItem.KitItem.GetValueOrDefault()) { string revisionId = Graph.KitProduct.SelectSingle(inventoryItem.InventoryID)?.RevisionID; IEnumerable <INKitSpecStkDet> stockKitComponents = Graph.StockKitComponents.Select(inventoryItem.InventoryID, revisionId)?.RowCast <INKitSpecStkDet>(); IEnumerable <INKitSpecNonStkDet> nonStockKitComponents = Graph.NonStockKitComponents.Select(inventoryItem.InventoryID, revisionId)?.RowCast <INKitSpecNonStkDet>(); childIds.AddRange(stockKitComponents.Select(x => x.CompInventoryID.GetValueOrDefault())); childIds.AddRange(nonStockKitComponents.Select(x => x.CompInventoryID.GetValueOrDefault())); } result = childIds.Count == 0 || childIds.All(child => validIds.Contains(child)); return(result); }
/// <summary> /// Check whether parent of composite child item is valid. /// </summary> /// <param name="inventoryItem">Grouped/Configurable Product/Kit that should be checked</param> /// <returns>Validation result</returns> private bool Validate(InventoryItem inventoryItem) { List <int> validIds = InputList.Select(validItem => validItem.InventoryID.GetValueOrDefault()).ToList(); //List<int> childIds = new List<int>(); bool result = true; InventoryItemPCExt itemPCExt = inventoryItem.GetExtension <InventoryItemPCExt>(); if (itemPCExt != null && itemPCExt.UsrKNCompositeType == null) { if (itemPCExt.UsrKNCompositeID != null) { result = validIds.Contains(itemPCExt.UsrKNCompositeID.Value); if (!result) { return(result); } } if (inventoryItem.StkItem.GetValueOrDefault()) { PXResultset <INKitSpecStkDet> stockComponents = Graph.StockKitComponentsExisted.Select(inventoryItem.InventoryID); foreach (INKitSpecStkDet comp in stockComponents) { string revisionId = Graph.KitProduct.SelectSingle(comp.KitInventoryID)?.RevisionID; if (comp.RevisionID == revisionId) { result = validIds.Contains(comp.KitInventoryID.Value); } if (result) { return(result); } } } else { PXResultset <INKitSpecNonStkDet> nonStockComponents = Graph.NonStockKitComponentsExisted.Select(inventoryItem.InventoryID); foreach (INKitSpecNonStkDet comp in nonStockComponents) { string revisionId = Graph.KitProduct.SelectSingle(comp.KitInventoryID)?.RevisionID; if (comp.RevisionID == revisionId) { result = validIds.Contains(comp.KitInventoryID.Value); } if (result) { return(result); } } } } return(result); }
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { InputList = value as IEnumerable <object>; SetDefaultSeperatorIfNecessary(); if (HasInputList) { return(String.Join(Seperator.ToString() + " ", InputList.Select(o => o.ToString()).ToArray())); } else { return(DefaultReturnValue); } }