/// <summary>
        ///     Removes an item from the database completely.
        /// </summary>
        /// <param name="itemDefinition">Used to identify the particular item</param>
        /// <param name="context"></param>
        /// <returns></returns>
        public override bool DeleteItem(ItemDefinition itemDefinition, CallContext context)
        {
            if (ItemsById.ContainsKey(itemDefinition.ID))
            {
                // recursively remove descendants
                foreach (var child in ItemsByParentId.Where(item => item.Key == itemDefinition.ID))
                {
                    DeleteItem(
                        new ItemDefinition(ParseId(child.Value.ID), child.Value.Name, ParseId(child.Value.TemplateID),
                                           ParseId(child.Value.BranchId)), context);
                }

                // remove the item
                ItemsById.Remove(itemDefinition.ID);
                foreach (
                    var remove in
                    ItemsByParentId.Where(
                        it => it.Value != null && it.Value.ID.Equals(GetIdAsString(itemDefinition.ID))).ToList())
                {
                    ItemsByParentId.Remove(remove);
                }
                return(true);
            }

            return(false);
        }
        /// <summary>
        ///     Determines what items are children of the item and returns a list of their IDs.
        /// </summary>
        /// <param name="itemDefinition">Used to identify the particular item</param>
        /// <param name="context"></param>
        /// <returns></returns>
        public override IDList GetChildIDs(ItemDefinition itemDefinition, CallContext context)
        {
            IEnumerable <KeyValuePair <ID, SyncItem> > childItems =
                ItemsByParentId.Where(item => item.Key == itemDefinition.ID);

            return(IDList.Build(childItems.Select(item => ParseId(item.Value.ID)).ToArray()));
        }