/// <summary>
        /// Relocate an item
        /// </summary>
        /// <param name="item">Item to move</param>
        /// <param name="newParent">Item which will become the parent</param>
        /// <param name="source">Item responsible for doing the moving</param>
        public Item Move(Item item, Item newParent, Item source = null)
        {
            var oldLocation = ItemRepo.Read(item.ParentId.Value);

            // Update item's location
            item.Parent   = newParent;
            item.ParentId = newParent.Id;
            ItemRepo.Update(item);
            var newLocation = ItemRepo.Read(newParent.Id);
            // Send messages
            var moveItemEvent = new CoreMoveItemEvent()
            {
                Item      = ItemRepo.Read(item.Id),
                OldParent = oldLocation,
                NewParent = newParent,
                Source    = source
            };
            var messageManager = ModuleManager.GetManager <IMessageManager>();
            var recipients     = new List <Item>();
            var addRecipients  = new List <Item>();

            addRecipients.AddRange(oldLocation.Children);
            addRecipients.AddRange(newLocation.Children);
            addRecipients.Add(oldLocation);
            addRecipients.Add(newLocation);
            addRecipients.ForEach(recipient =>
            {
                if (!recipients.Select(x => x.Id).ToList().Contains(recipient.Id))
                {
                    recipients.Add(recipient);
                }
            });
            ItemMoveEvent?.Invoke(moveItemEvent);
            messageManager.SendMessage(new List <IMessage>()
            {
                moveItemEvent
            }, recipients);
            return(item);
        }
Beispiel #2
0
 public void OnItemMove(ItemMoveEvent be)
 {
     this.Invoke("On_ItemMove", new object[] { be });
 }
Beispiel #3
0
 public void OnItemMove(ItemMoveEvent be)
 {
     Invoke("On_ItemMove", be);
 }