public void NormalizeItemRelations() { if (ItemRelations.Count == 0 || IsFirst != null) { return; } foreach (var itemRelation in ItemRelations.Where(i => i.FirstItemId != ItemId && i.FirtsItemTypeId != SmartCoreObjectType.ItemId)) { itemRelation.SecondItemId = itemRelation.FirstItemId; itemRelation.SecondItemTypeId = itemRelation.FirtsItemTypeId; itemRelation.FirstItemId = ItemId; itemRelation.FirtsItemTypeId = SmartCoreObjectType.ItemId; if (itemRelation.RelationTypeId == WorkItemsRelationType.CalculationAffect) { itemRelation.RelationTypeId = WorkItemsRelationType.CalculationDepend; } else if (itemRelation.RelationTypeId == WorkItemsRelationType.CalculationDepend) { itemRelation.RelationTypeId = WorkItemsRelationType.CalculationAffect; } } }
public void RemoveItems(string[] itemIds) { var items = GetItemByIds(itemIds); foreach (var item in items) { //Delete all variations RemoveItems(Items.Where(x => x.ParentId == item.Id).Select(x => x.Id).ToArray()); //delete all relations var allItemRelations = ItemRelations.Where(x => x.ChildItemId == item.Id || x.ParentItemId == item.Id); foreach (var relation in allItemRelations) { base.Remove(relation); } base.Remove(item); } }