public bool CheckBranches(KCSiteMasterMaint sitemaster, List <KCAPIOrderItem> orderItems, KCAPIOrder order) { BAccount customer = KCGeneralDataHelper.GetCustomerByCAOrder(sitemaster, order); if (customer == null) { logger.SetNonChildEntityId(order.ID.ToString()); logger.Information(KCMessages.CustomerNotFound(order.ID, order.BuyerEmailAddress)); return(false); } bool workflowPublished = new KCNamespaceReview().Test(KCConstants.NamespaceTesterPackage); if (workflowPublished) { bool validItem; foreach (KCAPIOrderItem item in orderItems) { DAC.KNSIKCInventoryItem stockItem = sitemaster.ExistingProducts.SelectSingle(item.ProductID); InventoryItem product = sitemaster.ProductByInvId.SelectSingle(stockItem.InventoryID); KCInventoryItemExt productKCExt = product.GetExtension <KCInventoryItemExt>(); validItem = false; if (product.GetExtension <InventoryItemPCExt>().UsrKNCompositeType == null) { if (productKCExt.UsrKNCPBranch != null && customer.GetExtension <KCCustomerExt>()?.UsrKNCPBranchID != null) { List <string> productBranches = productKCExt.UsrKNCPBranch.Split(',').ToList(); foreach (string branch in productBranches) { if (customer.GetExtension <KCCustomerExt>()?.UsrKNCPBranchID?.Split(',').Select(x => x.Trim()).ToList().Contains(branch) == true) { validItem = true; } } } else { validItem = true; } } else { validItem = true; } if (!validItem) { logger.SetNonChildEntityId(order.ID.ToString()); logger.Information(KCMessages.WebsitesAreNotAssociated(order.ID, product.InventoryCD, customer.AcctName)); return(false); } } } return(true); }