public IActionResult Index( int page = 1, string?searchString = null, string?sortBy = null, string sortDirection = GenericSortingHelper.Ascending, string?existingFilterString = null, string?newFilterToAdd = null, bool clearFilters = false, int?itemsPerPage = null ) { sortBy ??= DefaultSortByOptions.Name.PropertyName; existingFilterString = FilteringHelper.GetFilterString( existingFilterString, newFilterToAdd, clearFilters, Request, DelegateFilterCookieName, DelegateActiveStatusFilterOptions.IsActive.FilterValue ); var centreId = User.GetCentreId(); var jobGroups = jobGroupsDataService.GetJobGroupsAlphabetical(); var customPrompts = promptsService.GetCentreRegistrationPrompts(centreId).ToList(); var delegateUsers = userDataService.GetDelegateUserCardsByCentreId(centreId); var promptsWithOptions = customPrompts.Where(customPrompt => customPrompt.Options.Count > 0); var availableFilters = AllDelegatesViewModelFilterOptions.GetAllDelegatesFilterViewModels( jobGroups, promptsWithOptions ); var searchSortPaginationOptions = new SearchSortFilterAndPaginateOptions( new SearchOptions(searchString), new SortOptions(sortBy, sortDirection), new FilterOptions( existingFilterString, availableFilters, DelegateActiveStatusFilterOptions.IsActive.FilterValue ), new PaginationOptions(page, itemsPerPage) ); var result = searchSortFilterPaginateService.SearchFilterSortAndPaginate( delegateUsers, searchSortPaginationOptions ); var model = new AllDelegatesViewModel( result, customPrompts, availableFilters ); Response.UpdateFilterCookie(DelegateFilterCookieName, result.FilterString); return(View(model)); }
public IActionResult SelectDelegate( int groupId, string?searchString = null, string?existingFilterString = null, string?newFilterToAdd = null, bool clearFilters = false, int page = 1 ) { existingFilterString = FilteringHelper.GetFilterString( existingFilterString, newFilterToAdd, clearFilters, Request, AddGroupDelegateCookieName ); var centreId = User.GetCentreId(); var jobGroups = jobGroupsService.GetJobGroupsAlphabetical().ToList(); var customPrompts = promptsService.GetCentreRegistrationPrompts(centreId).ToList(); var delegateUsers = userService.GetDelegatesNotRegisteredForGroupByGroupId(groupId, centreId); var groupName = groupsService.GetGroupName(groupId, centreId); var promptsWithOptions = customPrompts.Where(customPrompt => customPrompt.Options.Count > 0); var availableFilters = GroupDelegatesViewModelFilterOptions.GetAddGroupDelegateFilterViewModels( jobGroups, promptsWithOptions ); var searchSortPaginationOptions = new SearchSortFilterAndPaginateOptions( new SearchOptions(searchString), new SortOptions( DefaultSortByOptions.Name.PropertyName, GenericSortingHelper.Ascending ), new FilterOptions(existingFilterString, availableFilters), new PaginationOptions(page) ); var result = searchSortFilterPaginateService.SearchFilterSortAndPaginate( delegateUsers, searchSortPaginationOptions ); var model = new AddGroupDelegateViewModel( result, availableFilters, customPrompts, groupId, groupName ! ); Response.UpdateFilterCookie(AddGroupDelegateCookieName, result.FilterString); return(View(model)); }
public IActionResult Index( string?existingFilterString = null, string?newFilterToAdd = null, bool clearFilters = false, bool selectAll = false ) { var newFilterString = FilteringHelper.GetFilterString( existingFilterString, newFilterToAdd, clearFilters, Request, EmailDelegateFilterCookieName ); var jobGroups = jobGroupsDataService.GetJobGroupsAlphabetical(); var customPrompts = promptsService.GetCentreRegistrationPrompts(User.GetCentreId()); var delegateUsers = GetDelegateUserCards(); var promptsWithOptions = customPrompts.Where(customPrompt => customPrompt.Options.Count > 0); var availableFilters = EmailDelegatesViewModelFilterOptions.GetEmailDelegatesFilterModels( jobGroups, promptsWithOptions ); var searchSortPaginationOptions = new SearchSortFilterAndPaginateOptions( null, null, new FilterOptions(newFilterString, availableFilters), null ); var result = searchSortFilterPaginateService.SearchFilterSortAndPaginate( delegateUsers, searchSortPaginationOptions ); var model = new EmailDelegatesViewModel( result, availableFilters, selectAll ); Response.UpdateFilterCookie(EmailDelegateFilterCookieName, result.FilterString); return(View(model)); }