public Resource Map(Match match, params string[] properties) { var resource = new Resource(new Link(_uriHelper.GetMatchUri(match.GameId, match.Id))); if (properties.Contains(HomeScore)) { resource.AddProperty(HomeScore, match.HomeScore); } if (properties.Contains(AwayScore)) { resource.AddProperty(AwayScore, match.AwayScore); } if (properties.Contains(CompetitionName)) { resource.AddProperty(CompetitionName, match.Round.CompetitionName); } if (properties.Contains(CompetitionType)) { resource.AddProperty(CompetitionType, match.Round.CompetitionType.ToString()); } if (properties.Contains(Round)) { resource.AddProperty(Round, match.Round.Name); } if (properties.Contains(Date)) { resource.AddProperty(Date, match.Date.ToString("dd-MMM")); } if (properties.Contains(Played)) { resource.AddProperty(Played, match.Played); } if (properties.Contains(PenaltiesTaken)) { resource.AddProperty(PenaltiesTaken, match.PenaltiesTaken); } if (properties.Contains(HomePenaltyScore)) { resource.AddProperty(HomePenaltyScore, match.HomePenaltyScore); } if (properties.Contains(AwayPenaltyScore)) { resource.AddProperty(AwayPenaltyScore, match.AwayPenaltyScore); } return(resource); }
public IEnumerable <Resource> Create(IEnumerable <TeamRoundMatch> matches, string gameId, string seasonId, string teamId) { var teamMapper = new TeamMapper(_uriHelper); var matchResources = new List <Resource>(); foreach (var match in matches) { var matchResource = new Resource(new Link(_uriHelper.GetMatchUri(match.GameId, match.MatchId))); matchResource.AddProperty("date", match.MatchDate.ToString("dd-MMM")); matchResource.AddProperty("competition-name", match.CompetitionName); matchResource.AddProperty("round", match.RoundName); matchResource.AddProperty("home-score", match.HomeScore); matchResource.AddProperty("away-score", match.AwayScore); matchResource.AddProperty("penalties-taken", match.PenaltiesTaken); matchResource.AddProperty("home-penalty-score", match.HomePenaltyScore); matchResource.AddProperty("away-penalty-score", match.AwayPenaltyScore); matchResource.AddProperty("played", match.Played); if (match.HomeTeam != null) { var homeTeamResource = teamMapper.Map(match.HomeTeam, TeamMapper.TeamName, TeamMapper.LeagueName, TeamMapper.CurrentLeaguePosition); matchResource.AddResource("home-team", homeTeamResource); } if (match.AwayTeam != null) { var awayTeamResource = teamMapper.Map(match.AwayTeam, TeamMapper.TeamName, TeamMapper.LeagueName, TeamMapper.CurrentLeaguePosition); matchResource.AddResource("away-team", awayTeamResource); } matchResources.Add(matchResource); } return(matchResources); }