public AllDelegateGroupsViewModel(List <Group> groups, IEnumerable <CentreRegistrationPrompt> registrationPrompts) { DelegateGroups = groups.Select(g => { var cardId = $"{g.GroupId}-card"; return(new SearchableDelegateGroupViewModel(g, new ReturnPageQuery(1, cardId))); } ); Filters = DelegateGroupsViewModelFilterOptions.GetDelegateGroupFilterModels(groups, registrationPrompts) .SelectAppliedFilterViewModels(); }
public AllDelegateGroupsViewModel(List <Group> groups, IEnumerable <CustomPrompt> registrationPrompts) { DelegateGroups = groups.Select(g => new SearchableDelegateGroupViewModel(g)); var admins = groups.Select(g => (g.AddedByAdminId, g.AddedByName)).Distinct(); Filters = new[] { new FilterViewModel( nameof(Group.AddedByAdminId), "Added by", DelegateGroupsViewModelFilterOptions.GetAddedByOptions(admins) ), new FilterViewModel( nameof(Group.LinkedToField), "Linked field", DelegateGroupsViewModelFilterOptions.GetLinkedFieldOptions(registrationPrompts) ) }.SelectAppliedFilterViewModels(); }
public DelegateGroupsViewModel( List <Group> groups, IEnumerable <CustomPrompt> registrationPrompts, string searchString, string sortBy, string sortDirection, string?filterBy, int page ) : base(searchString, page, true, sortBy, sortDirection, filterBy) { var sortedItems = GenericSortingHelper.SortAllItems( groups.AsQueryable(), sortBy, sortDirection ); var searchedItems = GenericSearchHelper.SearchItems(sortedItems, SearchString); var filteredItems = FilteringHelper.FilterItems(searchedItems.AsQueryable(), filterBy).ToList(); MatchingSearchResults = filteredItems.Count; SetTotalPages(); var paginatedItems = GetItemsOnCurrentPage(filteredItems); DelegateGroups = paginatedItems.Select(g => new SearchableDelegateGroupViewModel(g)); var admins = groups.Select(g => (g.AddedByAdminId, g.AddedByName)).Distinct(); Filters = new[] { new FilterViewModel( nameof(Group.AddedByAdminId), "Added by", DelegateGroupsViewModelFilterOptions.GetAddedByOptions(admins) ), new FilterViewModel( nameof(Group.LinkedToField), "Linked field", DelegateGroupsViewModelFilterOptions.GetLinkedFieldOptions(registrationPrompts) ) }; }