Skip to content

Instantly share code, notes, and snippets.

@hartviglarsen
Last active January 24, 2019 20:48
Show Gist options
  • Select an option

  • Save hartviglarsen/85a439f37349f3e33bd8365f6a71265f to your computer and use it in GitHub Desktop.

Select an option

Save hartviglarsen/85a439f37349f3e33bd8365f6a71265f to your computer and use it in GitHub Desktop.
if (bodyText.InvariantContains(product.Name))
{
if (relationService.AreRelated(doc, product, "product") == false)
{
relationService.Relate(doc, product, "product");
}
}
else
{
if (relationService.AreRelated(doc, product, "product") == true)
{
var type = relationService.GetRelationTypeByAlias("product");
var relations = relationService.GetAllRelationsByRelationType(type.Id)
.Where(x => x.ParentId == doc.Id && x.ChildId == product.Id);
foreach (var relation in relations)
{
relationService.Delete(relation);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment