Skip to content

Commit 113ebf1

Browse files
committed
Sort search results by LastName
GH-379
1 parent 28a5664 commit 113ebf1

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

Diff for: R7.University.Employees/Queries/EmployeeFindQuery.cs

+9-4
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,13 @@ public EmployeeFindQuery (IModelContext modelContext): base (modelContext)
1313
}
1414

1515
public IEnumerable<EmployeeInfo> FindEmployees (string search, bool teachersOnly, int divisionId)
16+
{
17+
return FindEmployees_Internal (search, teachersOnly, divisionId)
18+
.Distinct (new EntityEqualityComparer<EmployeeInfo> (e => e.EmployeeID))
19+
.OrderBy (e => e.LastName);
20+
}
21+
22+
IEnumerable<EmployeeInfo> FindEmployees_Internal (string search, bool teachersOnly, int divisionId)
1623
{
1724
// TODO: Reduce code duplication, see also Launchpad/EmployeesTable
1825
if (divisionId != -1) {
@@ -29,8 +36,7 @@ public IEnumerable<EmployeeInfo> FindEmployees (string search, bool teachersOnly
2936
|| e.Phone.Contains (search)
3037
|| e.Email.Contains (search)
3138
|| e.SecondaryEmail.Contains (search)
32-
|| e.WorkingPlace.Contains (search))
33-
.Distinct (new EntityEqualityComparer<EmployeeInfo> (e => e.EmployeeID));
39+
|| e.WorkingPlace.Contains (search));
3440
}
3541
return ModelContext.Query<EmployeeInfo> ()
3642
.IncludePositionsWithDivision ()
@@ -48,8 +54,7 @@ public IEnumerable<EmployeeInfo> FindEmployees (string search, bool teachersOnly
4854
|| e.SecondaryEmail.Contains (search)
4955
|| e.WorkingPlace.Contains (search)
5056
)
51-
.ToList ()
52-
.Distinct (new EntityEqualityComparer<EmployeeInfo> (e => e.EmployeeID));
57+
.ToList ();
5358
}
5459
}
5560
}

0 commit comments

Comments
 (0)