public ActionResult <ProductModel[]> GetType(string identity = null)
        {
            if (identity == null)
            {
                var products = _productManagement.LoadTypes(new ProductQuery {
                    Selector = Selector.Direct, ExcludeDerivedTypes = false
                })
                               .ToList();
                var productModels = new List <ProductModel>();
                foreach (var p in products)
                {
                    productModels.Add(_productConverter.ConvertProduct(p, false));
                }
                return(productModels.ToArray());
            }

            var identityArray = WebUtility.HtmlEncode(identity).Split('-');

            if (identityArray.Length != 2)
            {
                return(BadRequest($"Identity has wrong format. Must be identifier-revision"));
            }
            var productIdentity = new ProductIdentity(identityArray[0], Convert.ToInt16(identityArray[1]));
            var productType     = _productManagement.LoadType(productIdentity);

            if (productType == null)
            {
                return(NotFound());
            }
            return(new ProductModel[] { _productConverter.ConvertProduct(productType, false) });
        }
        private void UpdateCollection(IList value, IEnumerable <PartModel> parts)
        {
            // Track which part links are still represented by the models
            var unused = new List <IProductPartLink>(value.OfType <IProductPartLink>());
            // Iterate over the part models
            // Create or update the part links
            var elemType = value.GetType().GetInterfaces()
                           .Where(i => i.IsGenericType && i.GetGenericTypeDefinition() == typeof(IList <>))
                           .Select(i => i.GetGenericArguments()[0]).Single();

            foreach (var partModel in parts)
            {
                if (partModel is null)
                {
                    continue;
                }

                var match = unused.Find(r => r.Id == partModel?.Id);
                if (match == null)
                {
                    match = (IProductPartLink)Activator.CreateInstance(elemType);
                    value.Add(match);
                }
                else
                {
                    unused.Remove(match);
                }

                EntryConvert.UpdateInstance(match, partModel.Properties);
                match.Product = _productManagement.LoadType(partModel.Product.Id);
            }

            // Clear all values no longer present in the model
            foreach (var link in unused)
            {
                value.Remove(link);
            }
        }