public static Game ConverGeekGameToGame(BoardGameGeekGame geekGame)
        {
            Game game = new Game
            {
                Description = geekGame.Description,
                GeekID = geekGame.GeekID,
                MaxNumberOfPlayers = geekGame.MaxNumberOfPlayers,
                MinNumberOfPlayers = geekGame.MinNumberOfPlayers,
                Name = geekGame.Name,
                PlayTime = geekGame.PlayTime,
                ThumbNailURL = geekGame.ThumbNailURL
            };

            return game;
        }
예제 #2
0
        public static BoardGameGeekGame GetGameByGeekID(string geekID)
        {
            BoardGameGeekGame g = new BoardGameGeekGame();

            string queryURL = string.Format("{0}{1}{2}", BASE_URL, GAME_URL, geekID);
            XDocument xml = WebHelpers.GetXMLFromServer(queryURL);
            var gameDetails = xml.Root.Element("boardgame");

            g.GeekID = geekID;
            g.Name = gameDetails.Elements("name").Where(x => (x.Attribute("primary") != null && x.Attribute("primary").Value == "true")).Select(x => x.Value).Single();
            g.MaxNumberOfPlayers = int.Parse(gameDetails.Element("maxplayers").Value);
            g.MinNumberOfPlayers = int.Parse(gameDetails.Element("minplayers").Value);
            g.PlayTime = int.Parse(gameDetails.Element("playingtime").Value);
            g.ThumbNailURL = gameDetails.Element("thumbnail").Value;
            g.Description = gameDetails.Element("description").Value;
            g.YearPublished = gameDetails.Element("yearpublished").Value;

            if (DownloadBoardGameEvent != null)
            {
                EventHandler<DownloadEventArgs> downloadEvent = DownloadBoardGameEvent;
                downloadEvent(g, new DownloadEventArgs { CurrentItemCount = currentCount, TotalItemCount = totalCount, CurrentName = g.Name });
            }
            currentCount++;
            return g;
        }