public ActionResult <long> SaveType(ProductModel newTypeModel) { if (newTypeModel == null) { return(BadRequest($"Modified type was null")); } var type = ReflectionTool.GetPublicClasses <ProductType>(t => t.Name == newTypeModel.Type) .FirstOrDefault(); if (type == null) { return(NotFound()); } var productType = (ProductType)Activator.CreateInstance(type); var newType = _productConverter.ConvertProductBack(newTypeModel, productType); return(_productManagement.SaveType(newType)); }