Skip to content

Commit

Permalink
Merge pull request #33 from johnt84/LeagueGetNext5Fixtures
Browse files Browse the repository at this point in the history
Team Show Next 5 Fixtures
  • Loading branch information
johnt84 authored Aug 16, 2024
2 parents 19391e3 + 87ccf6a commit 7f7b1c8
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions FootballEngine/Logic/FixtureAndResultLogic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ public class FixtureAndResultLogic : IFixtureAndResultLogic
private readonly FootballDataModel _fixturesAndResultsFootballDataModel;
private readonly FootballEngineInput _footballEngineInput;

private const int NextFiveFixtures = 5;

public FixtureAndResultLogic(FootballDataModel fixturesAndResultsFootballDataModel, FootballEngineInput footballEngineInput)
{
_fixturesAndResultsFootballDataModel = fixturesAndResultsFootballDataModel;
Expand Down Expand Up @@ -66,12 +68,14 @@ public FootballShared.Models.Team GetFixturesAndResultsByTeam(FootballShared.Mod
.ToList();

var teamsFixturesAndResultsByDays = teamsFixtures
.Where(x => x.FixtureDate.Date > DateTime.UtcNow)
.GroupBy(x => x.FixtureDate.Date)
.Select(x => new FixturesAndResultsByDay()
{
FixtureDate = x.Key,
FixturesAndResults = x.ToList(),
})
.Take(NextFiveFixtures)
.ToList();

team.FixturesAndResultsByDays = teamsFixturesAndResultsByDays;
Expand Down

0 comments on commit 7f7b1c8

Please sign in to comment.