public async Task <IActionResult> Index( [Bind("LastName")] UserInformationAdminSearchDto searchDto = null, [Bind("SortOrder,CurrentSort,CurrentFilter,SearchString,IncludedProperties,Page,PageNumber,PageSize")] PageListActionDto pageListActionDto = null, Guid?id = null) { var viewModel = await _service.GetIndexViewAsync(searchDto, pageListActionDto, id); return(View(viewModel)); }
public async Task <UserInfoAdminIndexViewModel> GetIndexViewAsync(UserInformationAdminSearchDto searchDto, PageListActionDto pageListActionDto, Guid?id) { var indexViewModel = new UserInfoAdminIndexViewModel(); if (pageListActionDto == null) { pageListActionDto = new PageListActionDto(); } if (searchDto == null) { searchDto = new UserInformationAdminSearchDto(); } indexViewModel.SearchDto = searchDto; //This section used to set ascending or descending order indexViewModel.SortDto.FirstName = String.IsNullOrEmpty(pageListActionDto.SortOrder) ? "FirstName_desc" : ""; indexViewModel.SortDto.LastName = pageListActionDto.SortOrder == "LastName" ? "LastName_desc" : "LastName"; indexViewModel.SortDto.UserName = pageListActionDto.SortOrder == "UserName" ? "UserName_desc" : "UserName"; indexViewModel.Title = "Manage " + _TitleDesc + "s"; pageListActionDto.PageSize = 10; indexViewModel.PageListAction.CurrentSort = pageListActionDto.SortOrder; //var userInformations = await _unitOfWork.ApplicationUserRepository.GetAsync(ExpressionBuilder<ApplicationUser>.GetExpression(searchDto), // GetSortOrder(pageListActionDto.SortOrder), ""); var userInformations = await _unitOfWork.ApplicationUserRepository.GetAsync(await UserSearch(searchDto), GetSortOrder(pageListActionDto.SortOrder), ""); indexViewModel.UserInformations = await userInformations .ToPagedListAsync((pageListActionDto.Page ?? 1), pageListActionDto.PageSize); //Add items for selected user if (id != null) { var selectedUserInformation = await _unitOfWork.ApplicationUserRepository.SingleOrDefaultAsync( u => u.Id == id, "ApplicationUserUserRoles,ApplicationUserUserRoles.ApplicationUserRole"); indexViewModel.SelectedUserInformation = selectedUserInformation; } return(indexViewModel); }
public UserInfoAdminIndexViewModel() { SearchDto = new UserInformationAdminSearchDto(); SortDto = new UserInformationAdminSortDto(); PageListAction = new PageListActionDto(); }