public List <RefereeWithCurrentSeasonFixtureCount> GetAllRefereesWithCurrentSeasonFixtureCount() { List <Referee> refs = refereeRepository.Get().ToList(); List <Fixture> currentSeasonFixtures = fixtureService.GetAllFixturesForCurrentSeason(); List <RefereeWithCurrentSeasonFixtureCount> refsWithFixtureCount = new List <RefereeWithCurrentSeasonFixtureCount>(); foreach (Referee referee in refs) { RefereeWithCurrentSeasonFixtureCount refWithCount = new RefereeWithCurrentSeasonFixtureCount(referee, currentSeasonFixtures.Where(x => (x.Referee1 != null && x.Referee1.Id == referee.Id) || (x.Referee2 != null && x.Referee2.Id == referee.Id)).Count()); refsWithFixtureCount.Add(refWithCount); } return(refsWithFixtureCount.OrderBy(x => x.Referee.Forename).ToList()); }