Skip to content

Commit

Permalink
Merge pull request #178 from MarisaGoergen/fix/createRevisionsWithEnd…
Browse files Browse the repository at this point in the history
…point

Fix creating product revisions with endpoint
  • Loading branch information
1nf0rmagician authored Jul 20, 2022
2 parents 4486e90 + 8ed7620 commit 44d44aa
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -195,11 +195,14 @@ public IProductType ConvertProductBack(ProductModel source, ProductType converte
_productManagement.SaveRecipe(recipe);

// Delete recipes
var recipesOfProduct = _productManagement.GetRecipes(converted, RecipeClassification.CloneFilter);
foreach (var recipe in recipesOfProduct)
if (recipes.FirstOrDefault(r => r.Id == recipe.Id) == null)
_productManagement.RemoveRecipe(recipe.Id);

if(converted.Id != 0)
{
var recipesOfProduct = _productManagement.GetRecipes(converted, RecipeClassification.CloneFilter);
foreach (var recipe in recipesOfProduct)
if (recipes.FirstOrDefault(r => r.Id == recipe.Id) == null)
_productManagement.RemoveRecipe(recipe.Id);
}

// Product is flat
if (source.Properties is null)
return converted;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,8 @@ public IReadOnlyList<IProductRecipe> GetRecipes(IProductType productType, Recipe
{
ValidateHealthState();
var recipes = RecipeManagement.GetRecipes(productType, classification);
if (recipes == null)
return null;
return recipes.Select(ReplaceOrigin).ToArray();
}

Expand Down

0 comments on commit 44d44aa

Please sign in to comment.