public void Undo() { if (!Executed) { throw new CommandNotExecutedException(); } if (!_Db.RemoveLink(_ParentNode, _ChildNode)) { throw new CommandFailedDbWriteException(); } _ParentNode.RemoveChild(_ChildNode); _ChildNode.RemoveParent(_ParentNode); Executed = false; }
public void Execute() { if (Executed) { throw new CommandAlreadyExecutedException(); } if (!_Db.RemoveLink(_ParentNode, _ChildNode)) { throw new CommandFailedDbWriteException(); } _ParentNode.RemoveChild(_ChildNode); _ChildNode.RemoveParent(_ParentNode); Executed = true; }