Ejemplo n.º 1
0
        public Resource Map(Season season, params string[] properties)
        {
            var resource = new Resource(new Link(_uriHelper.GetSeasonUri(season.GameId, season.Id)));

            if (properties.Contains(SeasonShortName))
            {
                resource.AddProperty(SeasonShortName, season.ShortName);
            }

            if (properties.Contains(SeasonLongName))
            {
                resource.AddProperty(SeasonLongName, season.LongName);
            }

            return(resource);
        }
Ejemplo n.º 2
0
        public Resource Map(SeasonStatistics seasonStatistics, params string[] properties)
        {
            bool applyAllProperties = !properties.Any();

            var teamMapper = new TeamMapper(_uriHelper);

            var resource = new Resource(new Link(_uriHelper.GetSeasonUri(seasonStatistics.GameId, seasonStatistics.Id)));

            if (applyAllProperties || properties.Contains(SeasonShortName))
            {
                resource.AddProperty(SeasonShortName, seasonStatistics.Season.ShortName);
            }

            if (applyAllProperties || properties.Contains(SeasonLongName))
            {
                resource.AddProperty(SeasonLongName, seasonStatistics.Season.LongName);
            }

            if (applyAllProperties || properties.Contains(NationalChampion) && seasonStatistics.NationalChampion != null)
            {
                var team = teamMapper.Map(seasonStatistics.NationalChampion, TeamMapper.TeamName);
                resource.AddResource(NationalChampion, team);
            }

            if (applyAllProperties || properties.Contains(NationalChampionRunnerUp) && seasonStatistics.NationalChampionRunnerUp != null)
            {
                var team = teamMapper.Map(seasonStatistics.NationalChampionRunnerUp, TeamMapper.TeamName);
                resource.AddResource(NationalChampionRunnerUp, team);
            }

            if (applyAllProperties || properties.Contains(NationalCupWinner) && seasonStatistics.CupWinner != null)
            {
                var team = teamMapper.Map(seasonStatistics.CupWinner, TeamMapper.TeamName);
                resource.AddResource(NationalCupWinner, team);
            }

            if (applyAllProperties || properties.Contains(NationalCupRunnerUp) && seasonStatistics.CupRunnerUp != null)
            {
                var team = teamMapper.Map(seasonStatistics.CupRunnerUp, TeamMapper.TeamName);
                resource.AddResource(NationalCupRunnerUp, team);
            }

            return(resource);
        }