public string Search(RoleUserSearchRequestDto searchModel) { var gridParam = GetGridParams(); var list = _roleUserService.Search(searchModel, ref gridParam); return(JSONHelper.ToJson(list, gridParam == null ? list.Count : gridParam.TotalCount)); }
public List <RoleUserSearchResultDto> Search(RoleUserSearchRequestDto searchRequest, ref GridParams gridParams) { var query = from roleUser in _roleUserRepository.Table join role in _roleMasterRepository.Table on roleUser.RoleID equals role.RoleID join user in _userMasterRepository.Table on roleUser.UserID equals user.UserID select new RoleUserSearchResultDto() { UserRoleID = roleUser.UserRoleID, RoleID = role.RoleID, RoleDesc = role.RoleDesc, UserID = user.UserID, UserName = user.UserName }; query = query.Where(b => !( (searchRequest.UserRoleID != 0 && b.UserRoleID != searchRequest.UserRoleID) || (!string.IsNullOrEmpty(searchRequest.UserID) && b.UserID.Trim() != searchRequest.UserID) || (searchRequest.RoleID != 0 && b.RoleID != searchRequest.RoleID) )); gridParams.TotalCount = query.Count(); return(QueryExtensions.SortAndPage(query, gridParams).ToList()); }