示例#1
0
        public Task <WeekMatchupsVersioned> MapAsync(string httpResponse, WeekInfo week)
        {
            XElement weekGameXml = XElement.Parse(httpResponse);

            XElement gamesNode = weekGameXml.Elements("gms").Single();

            var model = new WeekMatchupsVersioned
            {
                Week  = week,
                Games = new List <WeekMatchupsVersioned.Game>()
            };

            foreach (XElement game in gamesNode.Elements("g"))
            {
                int    homeTeamId = Teams.GetIdFromAbbreviation(game.Attribute("h").Value, includePriorLookup: true);
                int    awayTeamId = Teams.GetIdFromAbbreviation(game.Attribute("v").Value, includePriorLookup: true);
                string nflGameId  = game.Attribute("eid").Value;
                string gsisGameId = game.Attribute("gsis").Value;

                var matchup = new WeekMatchupsVersioned.Game
                {
                    HomeTeamId = homeTeamId,
                    AwayTeamId = awayTeamId,
                    NflGameId  = nflGameId,
                    GsisGameId = gsisGameId
                };

                model.Games.Add(matchup);
            }

            return(Task.FromResult(model));
        }
示例#2
0
        public Task <List <WeekMatchup> > MapAsync(WeekMatchupsVersioned versionedModel, WeekInfo week)
        {
            var result = new List <WeekMatchup>();

            foreach (WeekMatchupsVersioned.Game game in versionedModel.Games)
            {
                result.Add(new WeekMatchup
                {
                    Week       = versionedModel.Week,
                    HomeTeamId = game.HomeTeamId,
                    AwayTeamId = game.AwayTeamId,
                    NflGameId  = game.NflGameId,
                    GsisGameId = game.GsisGameId
                });
            }

            return(Task.FromResult(result));
        }