// NEXT STATION: Views/DisplayManagement/AdHocShape.cshtml

        // First, create a page that will display a summary and some additional data of the book.
        // See it under /Lombiq.TrainingDemo/DisplayManagement/DisplayBook.
        public async Task <ActionResult> DisplayBook()
        {
            // For demonstration purposes create a dummy book object.
            var book = CreateDemoBook();

            // This method will generate a shape primarily for displaying information about the given object.
            var shape = await _bookDisplayManager.BuildDisplayAsync(book, this);

            // We will see how this display shape is generated and what will contain but first let's see how is this
            // rendered in the MVC view.
            // NEXT STATION: Go to Views/DisplayManagement/DisplayBook.cshtml.

            return(View(shape));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Display(string sitemapId)
        {
            if (!await _authorizationService.AuthorizeAsync(User, Permissions.ManageSitemaps))
            {
                return(Forbid());
            }

            var sitemap = await _sitemapManager.GetSitemapAsync(sitemapId);

            if (sitemap == null)
            {
                return(NotFound());
            }

            var items = new List <dynamic>();

            foreach (var source in sitemap.SitemapSources)
            {
                dynamic item = await _displayManager.BuildDisplayAsync(source, _updateModelAccessor.ModelUpdater, "SummaryAdmin");

                item.SitemapId     = sitemap.SitemapId;
                item.SitemapSource = source;
                items.Add(item);
            }

            var thumbnails = new Dictionary <string, dynamic>();

            foreach (var factory in _sourceFactories)
            {
                var     source    = factory.Create();
                dynamic thumbnail = await _displayManager.BuildDisplayAsync(source, _updateModelAccessor.ModelUpdater, "Thumbnail");

                thumbnail.SitemapSource     = source;
                thumbnail.SitemapSourceType = factory.Name;
                thumbnail.Sitemap           = sitemap;
                thumbnails.Add(factory.Name, thumbnail);
            }

            var model = new DisplaySitemapViewModel
            {
                Sitemap    = sitemap,
                Items      = items,
                Thumbnails = thumbnails,
            };

            return(View(model));
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> Index(ContentOptions options, PagerParameters pagerParameters)
        {
            if (!await _authorizationService.AuthorizeAsync(User, Permissions.ManageQueries))
            {
                return(Forbid());
            }

            var siteSettings = await _siteService.GetSiteSettingsAsync();

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

            var queries = await _queryManager.ListQueriesAsync();

            queries = queries.OrderBy(x => x.Name);

            if (!string.IsNullOrWhiteSpace(options.Search))
            {
                queries = queries.Where(q => q.Name.IndexOf(options.Search, StringComparison.OrdinalIgnoreCase) >= 0);
            }

            var results = queries
                          .Skip(pager.GetStartIndex())
                          .Take(pager.PageSize)
                          .ToList();

            // 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(queries.Count()).RouteData(routeData);

            var model = new QueriesIndexViewModel
            {
                Queries          = new List <QueryEntry>(),
                Options          = options,
                Pager            = pagerShape,
                QuerySourceNames = _querySources.Select(x => x.Name).ToList()
            };

            foreach (var query in results)
            {
                model.Queries.Add(new QueryEntry
                {
                    Query = query,
                    Shape = await _displayManager.BuildDisplayAsync(query, _updateModelAccessor.ModelUpdater, "SummaryAdmin")
                });
            }

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

            return(View(model));
        }
Ejemplo n.º 4
0
        public async Task <IActionResult> Display(int id)
        {
            if (!await _authorizationService.AuthorizeAsync(User, Permissions.ManageDeploymentPlan))
            {
                return(Forbid());
            }

            var deploymentPlan = await _session.GetAsync <DeploymentPlan>(id);

            if (deploymentPlan == null)
            {
                return(NotFound());
            }

            var items = new List <dynamic>();

            foreach (var step in deploymentPlan.DeploymentSteps)
            {
                dynamic item = await _displayManager.BuildDisplayAsync(step, _updateModelAccessor.ModelUpdater, "Summary");

                item.DeploymentStep = step;
                items.Add(item);
            }

            var thumbnails = new Dictionary <string, dynamic>();

            foreach (var factory in _factories)
            {
                var     step      = factory.Create();
                dynamic thumbnail = await _displayManager.BuildDisplayAsync(step, _updateModelAccessor.ModelUpdater, "Thumbnail");

                thumbnail.DeploymentStep = step;
                thumbnails.Add(factory.Name, thumbnail);
            }

            var model = new DisplayDeploymentPlanViewModel
            {
                DeploymentPlan = deploymentPlan,
                Items          = items,
                Thumbnails     = thumbnails,
            };

            return(View(model));
        }
Ejemplo n.º 5
0
        public async Task <IActionResult> Index(SearchIndexOptions options, PagerParameters pagerParameters)
        {
            //if (!await _authorizationService.AuthorizeAsync(User, Permissions.ManageQueries))
            //{
            //    return Unauthorized();
            //}

            var siteSettings = await _siteService.GetSiteSettingsAsync();

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

            // default options
            if (options == null)
            {
                options = new SearchIndexOptions();
            }

            var profiles = await _assesmentEngineManager.ListProfilesAsync();

            if (!string.IsNullOrWhiteSpace(options.Search))
            {
                profiles = profiles.Where(q => q.Name.IndexOf(options.Search, StringComparison.OrdinalIgnoreCase) >= 0);
            }

            var results = profiles
                          .Skip(pager.GetStartIndex())
                          .Take(pager.PageSize)
                          .ToList();

            // 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(profiles.Count()).RouteData(routeData);

            var model = new AssesmentProfilesIndexViewModel
            {
                Profiles = new List <AssesmentProfileEntry>(),
                Options  = options,
                Pager    = pagerShape,
                AssesmentTypeEngineNames = _assesmentEngineManager.GetEngines().Select(x => x.Name).ToList()
            };

            foreach (var profile in results)
            {
                model.Profiles.Add(new AssesmentProfileEntry
                {
                    Profile = profile,
                    Shape   = await _displayManager.BuildDisplayAsync(profile, this, "SummaryAdmin")
                });
            }

            return(View(model));
        }
Ejemplo n.º 6
0
        public async Task <IActionResult> Index(QueryIndexOptions options, PagerParameters pagerParameters)
        {
            if (!await _authorizationService.AuthorizeAsync(User, Permissions.ManageQueries))
            {
                return(Unauthorized());
            }

            var siteSettings = await _siteService.GetSiteSettingsAsync();

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

            // default options
            if (options == null)
            {
                options = new QueryIndexOptions();
            }

            var queries = await _queryManager.ListQueriesAsync();

            if (!string.IsNullOrWhiteSpace(options.Search))
            {
                queries = queries.Where(q => q.Name.IndexOf(options.Search, StringComparison.OrdinalIgnoreCase) >= 0);
            }

            var results = queries
                          .Skip(pager.GetStartIndex())
                          .Take(pager.PageSize)
                          .ToList();

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

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

            var pagerShape = New.Pager(pager).TotalItemCount(queries.Count()).RouteData(routeData);

            var model = new QueriesIndexViewModel
            {
                Queries          = new List <QueryEntry>(),
                Options          = options,
                Pager            = pagerShape,
                QuerySourceNames = _querySources.Select(x => x.Name).ToList()
            };

            foreach (var query in results)
            {
                model.Queries.Add(new QueryEntry {
                    Query = query,
                    Shape = await _displayManager.BuildDisplayAsync(query, this, "SummaryAdmin")
                });
            }

            return(View(model));
        }
Ejemplo n.º 7
0
        public static async Task <dynamic> BuildWidgetDisplay(ContentTypeDefinition contentTypeDefinition, string widgetTemplatePlaceholderId, string parentContentType, string partName, string prefixes, string contentTypes, string widgetAddClass, string displayType, IDisplayManager <ContentTypeDefinition> widgetDisplayManager)
        {
            dynamic activityShape = await widgetDisplayManager.BuildDisplayAsync(contentTypeDefinition, null, displayType);

            activityShape.Metadata.Type         = $"{nameof(ContentTypeDefinition)}_{displayType}"; //this maps to default shape ContentTypeDefinition.Thumbnail.cshtml. but can be overiden
            activityShape.ContentTypeDefinition = contentTypeDefinition;
            activityShape.Prefixes     = prefixes;
            activityShape.ContentTypes = contentTypes;
            activityShape.WidgetTemplatePlaceholderId = widgetTemplatePlaceholderId;
            activityShape.ParentContentType           = parentContentType;
            activityShape.PartName       = partName;
            activityShape.WidgetAddClass = widgetAddClass;
            // activityShape.WorkflowTypeId = workflowTypeId;
            //  activityShape.Index = index;
            // activityShape.ReturnUrl = Url.Action(nameof(Edit), new { id = workflowTypeId, localId = localId });
            return(activityShape);
        }
Ejemplo n.º 8
0
        public override IDisplayResult Display(ProjectionPart projectionpart, BuildPartDisplayContext context)
        {
            var shapeName = !String.IsNullOrEmpty(projectionpart.ProviderName) ? "ProjectionPart" : "ProjectionPart_Empty";

            return(Initialize <ProjectionDisplayPartViewModel>(shapeName, async model =>
            {
                model.ProjectionPart = projectionpart;

                if (!String.IsNullOrEmpty(projectionpart.ProviderName))
                {
                    //pass in existing object config object from metadtaa
                    var layoutProfile = JsonConvert.DeserializeObject <VisualProfile>(projectionpart.VisualMetadata,
                                                                                      new JsonSerializerSettings
                    {
                        TypeNameHandling = TypeNameHandling.All,
                        // $type no longer needs to be first
                        MetadataPropertyHandling = MetadataPropertyHandling.ReadAhead
                    });

                    //the actual query results
                    layoutProfile.QueryResult = await QueryResult(projectionpart.Query, projectionpart.Parameters);


                    var vm = new VisualsProviderViewModel
                    {
                        //here maybe create a content vm to pass in query results to display view

                        Editor = await _displayManager.BuildDisplayAsync(layoutProfile,
                                                                         context.Updater, "Detail"),
                        SourceName = projectionpart.ProviderName
                    };

                    //in the shape editor pass in other properties to consume in the view
                    //vm.Editor.Engine = _engineManager.GetEngineInstance(part.Profile);
                    //vm.Editor.SlideshowId = part.ContentItem.Id.ToString();

                    //the shape editor
                    model.DisplayVisualProvider = vm;
                    //the actual query results
                    //   model.QueryResult= await QueryResult(listPart.Query, listPart.Parameters);
                }
            })
                   .Location("Detail", "Content:10"));
            //.Location("DetailAdmin", "Content:10");
        }
Ejemplo n.º 9
0
        public async Task <IActionResult> Edit(string name)
        {
            if (!await _authorizationService.AuthorizeAsync(User, Permissions.ManageLayers))
            {
                return(Forbid());
            }

            var layers = await _layerService.GetLayersAsync();

            var layer = layers.Layers.FirstOrDefault(x => String.Equals(x.Name, name));

            if (layer == null)
            {
                return(NotFound());
            }

            dynamic rule = await _ruleDisplayManager.BuildDisplayAsync(layer.LayerRule, _updateModelAccessor.ModelUpdater, "Summary");

            rule.ConditionId = layer.LayerRule.ConditionId;

            var thumbnails = new Dictionary <string, dynamic>();

            foreach (var factory in _conditionFactories)
            {
                var     condition = factory.Create();
                dynamic thumbnail = await _conditionDisplayManager.BuildDisplayAsync(condition, _updateModelAccessor.ModelUpdater, "Thumbnail");

                thumbnail.Condition = condition;
                thumbnail.TargetUrl = Url.ActionLink("Create", "LayerRule", new { name = name, type = factory.Name });
                thumbnails.Add(factory.Name, thumbnail);
            }

            var model = new LayerEditViewModel
            {
                Name        = layer.Name,
                Description = layer.Description,
                LayerRule   = rule,
                Thumbnails  = thumbnails,
            };

            return(View(model));
        }
Ejemplo n.º 10
0
        // This page will display the books written by J.K. Rowling.
        // See it under /Lombiq.TrainingDemo/DatabaseStorage/JKRowlingBooks.
        public async Task <ActionResult> JKRowlingBooks()
        {
            // ISession service is used for querying items.
            var jkRowlingBooks = await _session
                                 // First, we define what object (document) we want to query and what index should be used for
                                 // filtering.
                                 .Query <Book, BookIndex>()
                                 // In the .Where() method you can describe a lambda where the object will be the index object.
                                 .Where(index => index.Author == "J.K. (Joanne) Rowling")
                                 // When the query is built up you can call ListAsync() to execute it. This will return a list of books.
                                 .ListAsync();

            // Now this is what we possibly understand now, we will create a list of display shapes from the previously
            // fetched books.
            var bookShapes = await Task.WhenAll(jkRowlingBooks.Select(async book =>
                                                                      await _bookDisplayManager.BuildDisplayAsync(book, this)));

            // You can check out Views/Store/JKRowlingBooks.cshtml and come back here.
            return(View(bookShapes));
        }
Ejemplo n.º 11
0
        private async Task <AdminNodeListViewModel> BuildDisplayViewModel(Models.AdminMenu tree)
        {
            var thumbnails = new Dictionary <string, dynamic>();

            foreach (var factory in _factories)
            {
                var     treeNode  = factory.Create();
                dynamic thumbnail = await _displayManager.BuildDisplayAsync(treeNode, _updateModelAccessor.ModelUpdater, "TreeThumbnail");

                thumbnail.TreeNode = treeNode;
                thumbnails.Add(factory.Name, thumbnail);
            }

            var model = new AdminNodeListViewModel
            {
                AdminMenu  = tree,
                Thumbnails = thumbnails,
            };

            return(model);
        }
Ejemplo n.º 12
0
        public async Task <ActionResult> Index(UserIndexOptions options, PagerParameters pagerParameters)
        {
            if (!await _authorizationService.AuthorizeAsync(User, Permissions.ManageUsers))
            {
                return(Unauthorized());
            }

            var siteSettings = await _siteService.GetSiteSettingsAsync();

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

            // default options
            if (options == null)
            {
                options = new UserIndexOptions();
            }

            var users = _session.Query <User, UserIndex>();

            switch (options.Filter)
            {
            case UsersFilter.Approved:
                //users = users.Where(u => u.RegistrationStatus == UserStatus.Approved);
                break;

            case UsersFilter.Pending:
                //users = users.Where(u => u.RegistrationStatus == UserStatus.Pending);
                break;

            case UsersFilter.EmailPending:
                //users = users.Where(u => u.EmailStatus == UserStatus.Pending);
                break;
            }

            if (!string.IsNullOrWhiteSpace(options.Search))
            {
                var normalizedSearchUserName = _userManager.NormalizeName(options.Search);
                var normalizedSearchEMail    = _userManager.NormalizeEmail(options.Search);

                users = users.Where(u => u.NormalizedUserName.Contains(normalizedSearchUserName) || u.NormalizedEmail.Contains(normalizedSearchEMail));
            }

            switch (options.Order)
            {
            case UsersOrder.Name:
                users = users.OrderBy(u => u.NormalizedUserName);
                break;

            case UsersOrder.Email:
                users = users.OrderBy(u => u.NormalizedEmail);
                break;

            case UsersOrder.CreatedUtc:
                //users = users.OrderBy(u => u.CreatedUtc);
                break;

            case UsersOrder.LastLoginUtc:
                //users = users.OrderBy(u => u.LastLoginUtc);
                break;
            }

            var count = await users.CountAsync();

            var results = await users
                          .Skip(pager.GetStartIndex())
                          .Take(pager.PageSize)
                          .ListAsync();

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

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

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

            var userEntries = new List <UserEntry>();

            foreach (var user in results)
            {
                userEntries.Add(new UserEntry
                {
                    Id    = user.Id,
                    Shape = await _userDisplayManager.BuildDisplayAsync(user, updater: this, displayType: "SummaryAdmin")
                }
                                );
            }

            var model = new UsersIndexViewModel
            {
                Users   = userEntries,
                Options = options,
                Pager   = pagerShape
            };

            model.Options.UserFilters = new List <SelectListItem>()
            {
                new SelectListItem()
                {
                    Text = TH["All"].Value, Value = nameof(UsersFilter.All)
                },
                //new SelectListItem() { Text = TH["Approved"].Value, Value = nameof(UsersFilter.Approved) },
                //new SelectListItem() { Text = TH["Email pending"].Value, Value = nameof(UsersFilter.EmailPending) },
                //new SelectListItem() { Text = TH["Pending"].Value, Value = nameof(UsersFilter.Pending) }
            };

            model.Options.UserSorts = new List <SelectListItem>()
            {
                new SelectListItem()
                {
                    Text = TH["Name"].Value, Value = nameof(UsersOrder.Name)
                },
                new SelectListItem()
                {
                    Text = TH["Email"].Value, Value = nameof(UsersOrder.Email)
                },
                //new SelectListItem() { Text = TH["Created date"].Value, Value = nameof(UsersOrder.CreatedUtc) },
                //new SelectListItem() { Text = TH["Last Login date"].Value, Value = nameof(UsersOrder.LastLoginUtc) }
            };

            model.Options.UsersBulkAction = new List <SelectListItem>()
            {
                new SelectListItem()
                {
                    Text = TH["Approve"].Value, Value = nameof(UsersBulkAction.Approve)
                },
                new SelectListItem()
                {
                    Text = TH["Enable"].Value, Value = nameof(UsersBulkAction.Enable)
                },
                new SelectListItem()
                {
                    Text = TH["Disable"].Value, Value = nameof(UsersBulkAction.Disable)
                },
                new SelectListItem()
                {
                    Text = TH["Delete"].Value, Value = nameof(UsersBulkAction.Delete)
                }
            };

            return(View(model));
        }
Ejemplo n.º 13
0
        public async Task <ActionResult> Index(UserIndexOptions options, PagerParameters pagerParameters)
        {
            if (!await _authorizationService.AuthorizeAsync(User, Permissions.ManageUsers))
            {
                return(Unauthorized());
            }

            var siteSettings = await _siteService.GetSiteSettingsAsync();

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

            // default options
            if (options == null)
            {
                options = new UserIndexOptions();
            }

            var users = _session.Query <User, UserIndex>();

            switch (options.Filter)
            {
            case UsersFilter.Approved:
                //users = users.Where(u => u.RegistrationStatus == UserStatus.Approved);
                break;

            case UsersFilter.Pending:
                //users = users.Where(u => u.RegistrationStatus == UserStatus.Pending);
                break;

            case UsersFilter.EmailPending:
                //users = users.Where(u => u.EmailStatus == UserStatus.Pending);
                break;
            }

            if (!string.IsNullOrWhiteSpace(options.Search))
            {
                users = users.Where(u => u.NormalizedUserName.Contains(options.Search) || u.NormalizedEmail.Contains(options.Search));
            }

            switch (options.Order)
            {
            case UsersOrder.Name:
                users = users.OrderBy(u => u.NormalizedUserName);
                break;

            case UsersOrder.Email:
                users = users.OrderBy(u => u.NormalizedEmail);
                break;

            case UsersOrder.CreatedUtc:
                //users = users.OrderBy(u => u.CreatedUtc);
                break;

            case UsersOrder.LastLoginUtc:
                //users = users.OrderBy(u => u.LastLoginUtc);
                break;
            }

            var count = await users.CountAsync();

            var results = await users
                          .Skip(pager.GetStartIndex())
                          .Take(pager.PageSize)
                          .ListAsync();

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

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

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

            var model = new UsersIndexViewModel
            {
                Users = await Task.WhenAll(
                    results.Select(async x =>
                                   new UserEntry {
                    Shape = await _userDisplayManager.BuildDisplayAsync(x, updater: this, displayType: "SummaryAdmin")
                })),
                Options = options,
                Pager   = pagerShape
            };

            return(View(model));
        }
Ejemplo n.º 14
0
        public async Task <ActionResult> Index([ModelBinder(BinderType = typeof(AuditTrailFilterEngineModelBinder), Name = "q")] QueryFilterResult <AuditTrailEvent> queryFilterResult, PagerParameters pagerParameters, string correlationId = "")
        {
            if (!await _authorizationService.AuthorizeAsync(User, AuditTrailPermissions.ViewAuditTrail))
            {
                return(Forbid());
            }

            var options = new AuditTrailIndexOptions
            {
                FilterResult = queryFilterResult
            };

            // This is used by Contents feature for routing so needs to be passed into the options.
            if (!String.IsNullOrEmpty(correlationId))
            {
                options.CorrelationId          = correlationId;
                options.CorrelationIdFromRoute = true;
            }

            if (options.CorrelationIdFromRoute)
            {
                // When the correlation id is provided via the route or options a placeholder node is used to apply a filter.
                options.FilterResult.TryAddOrReplace(new CorrelationIdFilterNode(options.CorrelationId));
            }

            var siteSettings = await _siteService.GetSiteSettingsAsync();

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

            // With the options populated we filter the query, allowing the filters to alter the options.
            var result = await _auditTrailAdminListQueryService.QueryAsync(pager.Page, pager.PageSize, options);

            // The search text is provided back to the UI.
            options.SearchText         = options.FilterResult.ToString();
            options.OriginalSearchText = options.SearchText;

            // Populate route values to maintain previous route data when generating page links.
            options.RouteValues.TryAdd("q", options.FilterResult.ToString());

            var pagerShape = await _shapeFactory.CreateAsync("Pager", Arguments.From(new
            {
                pager.Page,
                pager.PageSize,
                TotalItemCount = result.TotalCount
            }));

            var items = new List <IShape>();

            foreach (var auditTrailEvent in result.Events)
            {
                items.Add(
                    await _displayManager.BuildDisplayAsync(auditTrailEvent, updater: _updateModelAccessor.ModelUpdater, displayType: "SummaryAdmin")
                    );
            }

            var startIndex = (pager.Page - 1) * (pager.PageSize) + 1;

            options.StartIndex     = startIndex;
            options.EndIndex       = startIndex + items.Count - 1;
            options.EventsCount    = items.Count;
            options.TotalItemCount = result.TotalCount;

            var header = await _auditTrailOptionsDisplayManager.BuildEditorAsync(options, _updateModelAccessor.ModelUpdater, false);

            var shapeViewModel = await _shapeFactory.CreateAsync <AuditTrailListViewModel>("AuditTrailAdminList", viewModel =>
            {
                viewModel.Events  = items;
                viewModel.Pager   = pagerShape;
                viewModel.Options = options;
                viewModel.Header  = header;
            });

            return(View(shapeViewModel));
        }
Ejemplo n.º 15
0
        public async Task <ActionResult> Index([ModelBinder(BinderType = typeof(UserFilterEngineModelBinder), Name = "q")] QueryFilterResult <User> queryFilterResult, PagerParameters pagerParameters)
        {
            // Check a dummy user account to see if the current user has permission to view users.
            var authUser = new User();

            if (!await _authorizationService.AuthorizeAsync(User, Permissions.ViewUsers, authUser))
            {
                return(Forbid());
            }

            var options = new UserIndexOptions();

            // Populate route values to maintain previous route data when generating page links
            // await _userOptionsDisplayManager.UpdateEditorAsync(options, _updateModelAccessor.ModelUpdater, false);
            options.FilterResult = queryFilterResult;
            options.FilterResult.MapTo(options);

            // With the options populated we filter the query, allowing the filters to alter the options.
            var users = await _usersAdminListQueryService.QueryAsync(options, _updateModelAccessor.ModelUpdater);

            // The search text is provided back to the UI.
            options.SearchText         = options.FilterResult.ToString();
            options.OriginalSearchText = options.SearchText;

            // Populate route values to maintain previous route data when generating page links.
            options.RouteValues.TryAdd("q", options.FilterResult.ToString());

            var routeData = new RouteData(options.RouteValues);

            var siteSettings = await _siteService.GetSiteSettingsAsync();

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

            var count = await users.CountAsync();

            var results = await users
                          .Skip(pager.GetStartIndex())
                          .Take(pager.PageSize)
                          .ListAsync();

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

            var userEntries = new List <UserEntry>();

            foreach (var user in results)
            {
                userEntries.Add(new UserEntry
                {
                    UserId = user.UserId,
                    Shape  = await _userDisplayManager.BuildDisplayAsync(user, updater: _updateModelAccessor.ModelUpdater, displayType: "SummaryAdmin")
                }
                                );
            }

            options.UserFilters = new List <SelectListItem>()
            {
                new SelectListItem()
                {
                    Text = S["All Users"], Value = nameof(UsersFilter.All), Selected = (options.Filter == UsersFilter.All)
                },
                new SelectListItem()
                {
                    Text = S["Enabled Users"], Value = nameof(UsersFilter.Enabled), Selected = (options.Filter == UsersFilter.Enabled)
                },
                new SelectListItem()
                {
                    Text = S["Disabled Users"], Value = nameof(UsersFilter.Disabled), Selected = (options.Filter == UsersFilter.Disabled)
                }
                //new SelectListItem() { Text = S["Approved"], Value = nameof(UsersFilter.Approved) },
                //new SelectListItem() { Text = S["Email pending"], Value = nameof(UsersFilter.EmailPending) },
                //new SelectListItem() { Text = S["Pending"], Value = nameof(UsersFilter.Pending) }
            };

            options.UserSorts = new List <SelectListItem>()
            {
                new SelectListItem()
                {
                    Text = S["Name"], Value = nameof(UsersOrder.Name), Selected = (options.Order == UsersOrder.Name)
                },
                new SelectListItem()
                {
                    Text = S["Email"], Value = nameof(UsersOrder.Email), Selected = (options.Order == UsersOrder.Email)
                },
                //new SelectListItem() { Text = S["Created date"], Value = nameof(UsersOrder.CreatedUtc) },
                //new SelectListItem() { Text = S["Last Login date"], Value = nameof(UsersOrder.LastLoginUtc) }
            };

            options.UsersBulkAction = new List <SelectListItem>()
            {
                new SelectListItem()
                {
                    Text = S["Approve"], Value = nameof(UsersBulkAction.Approve)
                },
                new SelectListItem()
                {
                    Text = S["Enable"], Value = nameof(UsersBulkAction.Enable)
                },
                new SelectListItem()
                {
                    Text = S["Disable"], Value = nameof(UsersBulkAction.Disable)
                },
                new SelectListItem()
                {
                    Text = S["Delete"], Value = nameof(UsersBulkAction.Delete)
                }
            };

            var allRoles = (await _roleService.GetRoleNamesAsync())
                           .Except(new[] { "Anonymous", "Authenticated" }, StringComparer.OrdinalIgnoreCase);

            options.UserRoleFilters = new List <SelectListItem>()
            {
                new SelectListItem()
                {
                    Text = S["All roles"], Value = String.Empty, Selected = (options.SelectedRole == String.Empty)
                },
                new SelectListItem()
                {
                    Text = S["Authenticated (no roles)"], Value = "Authenticated", Selected = (String.Equals(options.SelectedRole, "Authenticated", StringComparison.OrdinalIgnoreCase))
                }
            };

            // TODO Candidate for dynamic localization.
            options.UserRoleFilters.AddRange(allRoles.Select(x => new SelectListItem {
                Text = x, Value = x, Selected = (String.Equals(options.SelectedRole, x, StringComparison.OrdinalIgnoreCase))
            }));

            // Populate options pager summary values.
            var startIndex = (pagerShape.Page - 1) * (pagerShape.PageSize) + 1;

            options.StartIndex     = startIndex;
            options.EndIndex       = startIndex + userEntries.Count - 1;
            options.UsersCount     = userEntries.Count;
            options.TotalItemCount = pagerShape.TotalItemCount;

            var header = await _userOptionsDisplayManager.BuildEditorAsync(options, _updateModelAccessor.ModelUpdater, false);

            var shapeViewModel = await _shapeFactory.CreateAsync <UsersIndexViewModel>("UsersAdminList", viewModel =>
            {
                viewModel.Users   = userEntries;
                viewModel.Pager   = pagerShape;
                viewModel.Options = options;
                viewModel.Header  = header;
            });

            return(View(shapeViewModel));
        }