Пример #1
0
        public async Task <IActionResult> Index()
        {
            if (!await _authorizationService.AuthorizeAsync(User, Permissions.ManageRemoteClients))
            {
                return(Unauthorized());
            }

            var remoteClientList = await _service.GetRemoteClientListAsync();

            var model = new RemoteClientIndexViewModel
            {
                RemoteClientList = remoteClientList
            };

            return(View(model));
        }
Пример #2
0
        public async Task <IActionResult> Index(ContentOptions options, PagerParameters pagerParameters)
        {
            if (!await _authorizationService.AuthorizeAsync(User, Permissions.ManageRemoteClients))
            {
                return(Forbid());
            }

            var siteSettings = await _siteService.GetSiteSettingsAsync();

            var pager = new Pager(pagerParameters, siteSettings.PageSize);

            var remoteClients = (await _remoteClientService.GetRemoteClientListAsync()).RemoteClients;

            if (!string.IsNullOrWhiteSpace(options.Search))
            {
                remoteClients = remoteClients.Where(x => x.ClientName.Contains(options.Search, StringComparison.OrdinalIgnoreCase)).ToList();
            }

            var count = remoteClients.Count();

            var startIndex = pager.GetStartIndex();
            var pageSize   = pager.PageSize;

            // Maintain previous route data when generating page links
            var routeData = new RouteData();

            routeData.Values.Add("Options.Search", options.Search);

            var pagerShape = (await New.Pager(pager)).TotalItemCount(count).RouteData(routeData);

            var model = new RemoteClientIndexViewModel
            {
                RemoteClients = remoteClients,
                Pager         = pagerShape,
                Options       = options
            };

            model.Options.ContentsBulkAction = new List <SelectListItem>()
            {
                new SelectListItem()
                {
                    Text = S["Delete"], Value = nameof(ContentsBulkAction.Remove)
                }
            };

            return(View(model));
        }
Пример #3
0
 public ActionResult IndexFilterPOST(RemoteClientIndexViewModel model)
 {
     return(RedirectToAction("Index", new RouteValueDictionary {
         { "Options.Search", model.Options.Search }
     }));
 }