예제 #1
0
        private void RaiseCreateDynamicContentItemInteractionRequest()
        {
            var item = CreateEntity <DynamicContentItem>();

            item.ContentTypeId = DynamicContentType.CategoryWithImage.ToString();

            var itemVM = _wizardVmFactory.GetViewModelInstance(
                new KeyValuePair <string, object>("item", item));

            CommonWizardDialogRequest.Raise(new ConditionalConfirmation
            {
                Title   = "Create dynamic content item".Localize(),
                Content = itemVM
            }, (x) =>
            {
                if (x.Confirmed)
                {
                    using (var repository = _dynamicContentRepository.GetRepositoryInstance())
                    {
                        repository.Add(item);
                        repository.UnitOfWork.Commit();
                    }

                    SelectedDynamicContentItems.Refresh();
                }
            });
        }
예제 #2
0
 private void DoSearchItems()
 {
     if (SelectedDynamicContentItems != null)
     {
         SelectedDynamicContentItems.Refresh();
     }
 }
예제 #3
0
        private void RaiseItemDuplicateInteractionRequest(IList selectedItemsList)
        {
            var selectionCount = selectedItemsList.Count;

            if (selectionCount > 0)
            {
                var selectedItems = selectedItemsList.Cast <VirtualListItem <IDynamicContentItemViewModel> >();
                var names         = selectedItems.
                                    Take(4).
                                    Select(x => ((ViewModelBase)x.Data).DisplayName);

                var joinedNames = string.Join(", ", names);
                if (selectionCount > 4)
                {
                    joinedNames += "...";
                }

                CommonConfirmRequest.Raise(new ConditionalConfirmation()
                {
                    Content = string.Format("Are you sure you want to duplicate '{0}'?".Localize(), joinedNames),
                    Title   = "Action confirmation".Localize(null, LocalizationScope.DefaultCategory)
                },
                                           (x) =>
                {
                    if (x.Confirmed)
                    {
                        using (var repository = _dynamicContentRepository.GetRepositoryInstance())
                        {
                            selectedItems.
                            ToList().
                            ForEach(y => y.Data.Duplicate(repository));

                            repository.UnitOfWork.Commit();
                        }

                        SelectedDynamicContentItems.Refresh();
                    }
                });
            }
        }
예제 #4
0
        private void RaiseItemDeleteInteractionRequest(IList selectedItemsList)
        {
            var selectionCount = selectedItemsList.Count;

            if (selectionCount > 0)
            {
                var selectedItems = selectedItemsList.Cast <VirtualListItem <IDynamicContentItemViewModel> >();
                var names         = selectedItems.
                                    Take(4).
                                    Select(x => ((ViewModelBase)x.Data).DisplayName);

                var joinedNames = string.Join(", ", names);
                if (selectionCount > 4)
                {
                    joinedNames += "...";
                }
                var restrictList = new List <DynamicContentItem>();
                using (var repository = _dynamicContentRepository.GetRepositoryInstance())
                {
                    foreach (var item in selectedItems)
                    {
                        var content = (item.Data as ViewModelDetailBase <DynamicContentItem>).InnerItem;
                        if (repository.PublishingGroups.Expand(publishing => publishing.ContentItems).Where(x => x.ContentItems.Any(i => i.DynamicContentItemId == content.DynamicContentItemId)).Count() > 0)
                        {
                            restrictList.Add(content);
                        }
                    }
                    if (restrictList.Any())
                    {
                        var dynamicNames = string.Empty;
                        var prefix       = restrictList.Count == 1 ? "Dynamic content".Localize() : "Dynamic contents".Localize();
                        restrictList.ForEach(x => dynamicNames = string.Join(Environment.NewLine, x.Name, dynamicNames));

                        var suffix = restrictList.Count == 1 ? "it's".Localize() : "they are".Localize();
                        CommonNotifyRequest.Raise(new Notification()
                        {
                            Content = string.Format("{0}{1} {2} can't be deleted as {3} used in Content Publishing".Localize(), prefix, Environment.NewLine, dynamicNames, suffix),
                            Title   = "Error".Localize(null, LocalizationScope.DefaultCategory)
                        });
                    }
                }

                if (!restrictList.Any())
                {
                    CommonConfirmRequest.Raise(new ConditionalConfirmation()
                    {
                        Content = string.Format("Are you sure you want to delete '{0}'?".Localize(null, LocalizationScope.DefaultCategory), joinedNames),
                        Title   = "Delete confirmation".Localize(null, LocalizationScope.DefaultCategory)
                    },
                                               async(x) =>
                    {
                        if (x.Confirmed)
                        {
                            try
                            {
                                OnUIThread(() => { ShowLoadingAnimation = true; });
                                await Task.Run(() =>
                                {
                                    foreach (var item in selectedItems)
                                    {
                                        (item.Data as IViewModelDetailBase).Delete();
                                    }
                                });
                                SelectedDynamicContentItems.Refresh();
                            }
                            finally
                            {
                                OnUIThread(() => { ShowLoadingAnimation = false; });
                            }
                        }
                    });
                }
            }
        }