public IEnumerable <GamePossession> GetGamePossessions(string username)
        {
            var ids   = _geekConnector.GetPossessedGameIds(username).ToList();
            var games = _boardGameRepository.GetBoardGames(ids.Select(i => i.Id)).ToList();

            var missingIds = ids.Where(id => !games.Select(g => g.Id).Contains(id.Id)).ToList();

            games.AddRange(missingIds.Select(CreateDummyGame));

            _boardGameRepository.StoreUnknownIds(missingIds.Select(id => id.Id));

            return(ids.Select(id => new GamePossession
            {
                BoardGame = games.First(g => g.Id == id.Id),
                Owner = username
            }));
        }
        // GET: api/BoardGames
        /// <summary>
        /// Gets all the Board games available.
        /// </summary>
        /// <returns>All Board Games elements in the Collection</returns>
        public HttpResponseMessage GetBoardGames()
        {
            var boardGames = _boardGame.GetBoardGames();

            if (boardGames != null)
            {
                return(Request.CreateResponse(HttpStatusCode.OK, boardGames));
            }
            return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "Board Games Collection not found"));
        }
 private void CollectBoardGames()
 {
     System.Diagnostics.Debug.WriteLine("CollectBoardGames started.");
     while (!_cancellationToken.IsCancellationRequested)
     {
         System.Diagnostics.Debug.WriteLine("CollectBoardGames loop entered.");
         var callIds = _idsToDo.GetConsumingEnumerable().Take(75).ToList();
         System.Diagnostics.Debug.WriteLine($"CollectBoardGames retrieved { callIds.Count } Ids.");
         var existingGames = _boardGameRepository.GetBoardGames(callIds.Select(id => id.Id)).ToList();
         System.Diagnostics.Debug.WriteLine($"CollectBoardGames skips { existingGames.Count } Ids.");
         callIds = callIds.Where(id => !existingGames.Select(eg => eg.Id).ToList().Contains(id.Id)).ToList();
         System.Diagnostics.Debug.WriteLine($"CollectBoardGames retrieved { callIds.Count } Ids.");
         var games = _geekConnector.RetrieveBoardGames(callIds.Select(i => i.Id).Distinct().ToArray());
         System.Diagnostics.Debug.WriteLine($"CollectBoardGames retrieved { callIds.Count } Games.");
         _boardGameRepository.StoreBoardGames(games);
         System.Diagnostics.Debug.WriteLine($"CollectBoardGames saved { callIds.Count } Games.");
     }
 }