public async Task <IActionResult> Index(PagerParameters pagerParameters) { if (!await _authorizationService.AuthorizeAsync(User, Permissions.ManageMediaProfiles)) { return(Forbid()); } var siteSettings = await _siteService.GetSiteSettingsAsync(); var pager = new Pager(pagerParameters, siteSettings.PageSize); var mediaProfilesDocument = await _mediaProfilesManager.GetMediaProfilesDocumentAsync(); var count = mediaProfilesDocument.MediaProfiles.Count; var mediaProfiles = mediaProfilesDocument.MediaProfiles.OrderBy(x => x.Key) .Skip(pager.GetStartIndex()) .Take(pager.PageSize); var pagerShape = (await New.Pager(pager)).TotalItemCount(count); var model = new MediaProfileIndexViewModel { MediaProfiles = mediaProfiles.Select(x => new MediaProfileEntry { Name = x.Key, MediaProfile = x.Value }).ToList(), Pager = pagerShape }; return(View("Index", model)); }
public async Task <IActionResult> Index(ContentOptions options, PagerParameters pagerParameters) { if (!await _authorizationService.AuthorizeAsync(User, Permissions.ManageMediaProfiles)) { return(Forbid()); } var siteSettings = await _siteService.GetSiteSettingsAsync(); var pager = new Pager(pagerParameters, siteSettings.PageSize); var mediaProfilesDocument = await _mediaProfilesManager.GetMediaProfilesDocumentAsync(); var mediaProfiles = mediaProfilesDocument.MediaProfiles.ToList(); if (!string.IsNullOrWhiteSpace(options.Search)) { mediaProfiles = mediaProfiles.Where(x => x.Key.Contains(options.Search, StringComparison.OrdinalIgnoreCase)).ToList(); } var count = mediaProfiles.Count; mediaProfiles = mediaProfiles.OrderBy(x => x.Key) .Skip(pager.GetStartIndex()) .Take(pager.PageSize).ToList(); var pagerShape = (await New.Pager(pager)).TotalItemCount(count); var model = new MediaProfileIndexViewModel { MediaProfiles = mediaProfiles.Select(x => new MediaProfileEntry { Name = x.Key, MediaProfile = x.Value }).ToList(), Pager = pagerShape }; model.Options.ContentsBulkAction = new List <SelectListItem>() { new SelectListItem() { Text = S["Delete"], Value = nameof(ContentsBulkAction.Remove) } }; return(View("Index", model)); }
public ActionResult IndexFilterPOST(MediaProfileIndexViewModel model) { return(RedirectToAction("Index", new RouteValueDictionary { { "Options.Search", model.Options.Search } })); }