public GridViewModel GetDepartmentSearchResult(SearchRequest request, int trustId) { var model = UserMapper.CreateDepartmentGridViewModel(); var pageResult = QueryListHelper.SortResults(GetAllDepartmentsByTrustId(trustId), request); var serviceRows = pageResult .Where(p => string.IsNullOrEmpty(request.SearchText) || p.DepartmentName.StartsWith(request.SearchText, StringComparison.CurrentCultureIgnoreCase)) .Select(UserMapper.BindDepartmentGridData); model.Rows = serviceRows.ToPagedList(request.Page ?? 1, request.PageSize); return(model); }