public void Move(TestNodeDto dto, int newParentId) { // TODO go to service then update the cache //update the cache mTestNodes.AddOrUpdate(new TestNodeDto(dto.Id, dto.Name, newParentId)); }
public void Remove(TestNodeDto dto) { // TODO go to service then updated the cache mTestNodes.Edit(updater => { //assign new parent to the children of the removed test node var childrenToMove = updater.Items .Where(tn => tn.ParentId == dto.Id) .Select(dto => new TestNodeDto(dto.Id, dto.Name, dto.ParentId)) .ToArray(); updater.AddOrUpdate(childrenToMove); //get rid of the existing test node updater.Remove(dto.Id); }); }