public ActionResult Index(FormCollection input)
        {
            var viewModel = new TagsAdminIndexViewModel {Tags = new List<TagEntry>(), BulkAction = new TagAdminIndexBulkAction()};
            
            if ( !TryUpdateModel(viewModel) ) {
                return View(viewModel);
            }

            IEnumerable<TagEntry> checkedEntries = viewModel.Tags.Where(t => t.IsChecked);
            switch (viewModel.BulkAction) {
                case TagAdminIndexBulkAction.None:
                    break;
                case TagAdminIndexBulkAction.Delete:
                    if (!Services.Authorizer.Authorize(Permissions.ManageTags, T("Couldn't delete tag")))
                        return new HttpUnauthorizedResult();

                    foreach (TagEntry entry in checkedEntries) {
                        _tagService.DeleteTag(entry.Tag.Id);
                    }
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
            }

            return RedirectToAction("Index");
        }
Beispiel #2
0
        public ActionResult Index() {
            if (!Services.Authorizer.Authorize(Permissions.ManageTags, T("Can't manage tags")))
                return new HttpUnauthorizedResult();

            IEnumerable<TagRecord> tags = _tagService.GetTags();
            var entries = tags.Select(CreateTagEntry).ToList();
            var model = new TagsAdminIndexViewModel { Tags = entries };
            return View(model);
        }
Beispiel #3
0
        public ActionResult Index(PagerParameters pagerParameters) {
            if (!Services.Authorizer.Authorize(Permissions.ManageTags, T("Can't manage tags")))
                return new HttpUnauthorizedResult();

            IEnumerable<TagRecord> tags = _tagService.GetTags();

            var pager = new Pager(Services.WorkContext.CurrentSite, pagerParameters);
            var pagerShape = Services.New.Pager(pager).TotalItemCount(tags.Count());
            if (pager.PageSize != 0) {
                tags = tags.Skip(pager.GetStartIndex()).Take(pager.PageSize);
            }

            var entries = tags.Select(CreateTagEntry).ToList();
            var model = new TagsAdminIndexViewModel { Pager = pagerShape, Tags = entries };

            return View(model);
        }
 public ActionResult Index()
 {
     try {
         IEnumerable<Tag> tags = _tagService.GetTags();
         var entries = tags.Select(tag => CreateTagEntry(tag)).ToList();
         var model = new TagsAdminIndexViewModel { Tags = entries };
         return View(model);
     }
     catch (Exception exception) {
         Services.Notifier.Error(T("Listing tags failed: " + exception.Message));
         return Index();
     }
 }
 public ActionResult Index() {
     IEnumerable<TagRecord> tags = _tagService.GetTags();
     var entries = tags.Select(CreateTagEntry).ToList();
     var model = new TagsAdminIndexViewModel { Tags = entries };
     return View(model);
 }