Пример #1
0
        public void MoveItem(ContainablePart item, ContainerPart targetContainer, int?position = null)
        {
            var commonPart = item.As <CommonPart>();

            if (commonPart == null)
            {
                throw new ArgumentException("Cannot move content that have no CommonPart", "item");
            }

            var previousContainer = commonPart.Container != null?commonPart.Container.As <ContainerPart>() : default(ContainerPart);

            commonPart.Container = targetContainer;

            if (previousContainer != null && previousContainer.Id != targetContainer.Id)
            {
                UpdateItemCount(previousContainer);
            }

            if (position != null)
            {
                item.Position = position.Value;
            }

            UpdateItemCount(targetContainer);
            UpdateItemPath(item.ContentItem);
        }
        private void UpdateItemCount(ContainablePart part) {
            var commonPart = part.As<CommonPart>();
            if (commonPart == null || commonPart.Container == null)
                return;

            var containerPart = commonPart.Container.As<ContainerPart>();
            if (containerPart == null)
                return;

            _containerService.UpdateItemCount(containerPart);
        }
Пример #3
0
        private void UpdateItemCount(ContainablePart part)
        {
            var commonPart = part.As <CommonPart>();

            if (commonPart == null || commonPart.Container == null)
            {
                return;
            }

            var containerPart = commonPart.Container.As <ContainerPart>();

            if (containerPart == null)
            {
                return;
            }

            _containerService.UpdateItemCount(containerPart);
        }