Exemple #1
0
        private List <RecycleItem> GetRecycleItems()
        {
            var pages        = _pageRepository.GetDeletedPages();
            var layouts      = _layoutRepository.GetDeletedLayouts();
            var pageContents = _pageContentRepository.GetDeletedPageContents();
            var pageModules  = _pageRepository.GetDeletedPageModules();

            var recycleItems        = new List <RecycleItem>();
            var allRecycleItemTypes = RecycleItemType.GetRecycleItemTypes();

            if (layouts != null && layouts.Count > 0)
            {
                recycleItems.AddRange(layouts.Select(layout => new RecycleItem()
                {
                    Id              = layout.Id,
                    Name            = layout.Name,
                    RecycleItemType = allRecycleItemTypes.First(rt => rt.Name == "Layouts")
                }));
            }

            if (pages != null && pages.Count > 0)
            {
                recycleItems.AddRange(pages.Select(page => new RecycleItem()
                {
                    Id              = page.Id,
                    Name            = page.PageTranslation.FirstOrDefault()?.Name,
                    RecycleItemType = allRecycleItemTypes.First(rt => rt.Name == "Page")
                }));
            }

            if (pageContents != null && pageContents.Count > 0)
            {
                recycleItems.AddRange(pageContents.Select(pc => new RecycleItem()
                {
                    Id              = pc.Id,
                    Name            = pc.Title,
                    RecycleItemType = allRecycleItemTypes.First(rt => rt.Name == "PageContent")
                }));
            }

            if (pageModules != null && pageModules.Count > 0)
            {
                recycleItems.AddRange(pageModules.Select(pm => new RecycleItem()
                {
                    Id = pm.Id, Name = pm.Title, RecycleItemType = allRecycleItemTypes.First(rt => rt.Name == "PageModule")
                }));
            }

            return(recycleItems);
        }
Exemple #2
0
        public void ConfigureAdmin(IAdminBuilder adminBuilder)
        {
            adminBuilder.RegisterGrid <RecycleItem, RecycleAdminService>(builder =>
            {
                builder.Title = "Recycle Bin";
                builder
                .AddKeyField(r => r.Id)
                .AddField(r => r.Name, option => option.DisplayName            = "Name / Title")
                .AddField(r => r.RecycleItemType, option => option.DisplayName = "Item Type");

                builder.DisplayFieldAs(c => c.Name, LabelType.Icon, c => c.RecycleItemTypeIconClass);

                builder.AddRowAction("Restore", "Restore",
                                     (provider, item) => provider.GetService <RecycleAdminService>().Restore(item));

                builder.Property(f => f.RecycleItemType).HasLookup(sp => RecycleItemType.GetRecycleItemTypes(),
                                                                   ke => ke.Id,
                                                                   de => de.Name);

                builder.HideEditButton();
            });
        }