/// <summary> /// Gets the system roles ListView model. /// </summary> /// <param name="selectModel">The select model.</param> /// <param name="nowpage">The nowpage.</param> /// <returns></returns> public SystemRolesViewModel GetSystemRolesListViewModel(SystemRolesListHeaderViewModel selectModel, int nowpage = 1) { SystemRolesViewModel returnSystemRolesListViewModel = new SystemRolesViewModel(); returnSystemRolesListViewModel.Header = selectModel; /*表頭*/ returnSystemRolesListViewModel.page = nowpage; IEnumerable <SystemRolesListContentViewModel> GetAllSystemRolesListViewModelResult = GetAllSystemRolesListViewModel(selectModel); int currentPage = (nowpage < 1) && GetAllSystemRolesListViewModelResult.Count() >= 1 ? 1 : nowpage; returnSystemRolesListViewModel.Content_List = GetAllSystemRolesListViewModelResult.ToPagedList(currentPage, pageSize);/*內容*/ return(returnSystemRolesListViewModel); }
/// <summary> /// Gets all system roles ListView model. /// </summary> /// <param name="selectModel">The select model.</param> /// <returns></returns> private IEnumerable <SystemRolesListContentViewModel> GetAllSystemRolesListViewModel(SystemRolesListHeaderViewModel selectModel) { IEnumerable <SystemRolesListContentViewModel> result = GetAllAspNetUsers().Where(s => (!string.IsNullOrEmpty(selectModel.UserName) ? s.UserName.ToUpper().Contains(selectModel.UserName.ToUpper()) : true) && (!string.IsNullOrWhiteSpace(selectModel.Email) ? s.Email.ToUpper().Contains(selectModel.Email.ToUpper()) : true) && s.Status == true).Select(List => new SystemRolesListContentViewModel() { Id = List.Id, Email = List.Email, UserName = List.UserName, PhoneNumber = List.PhoneNumber, LockoutEnabled = List.LockoutEnabled }).OrderByDescending(s => s.UserName).ToList(); return(result); }