Beispiel #1
0
        // Get the wishlist
        public async Task <List <Game> > GetWishlist(HomePage.ErrorHandling errorMessage, string id)
        {
            // Checks the internet connection
            bool connection = _checkConnection.hasConnection(errorMessage);

            if (connection)
            {
                // Checks the id isnt null
                if (id != null)
                {
                    // Gets the wishlist
                    var items = await _wishlistPlayedProxy.GetItems <Wishlist>(errorMessage, "Wishlist", id);

                    // If it was able to get items back
                    if (items != null)
                    {
                        List <Game> games = new List <Game>();

                        // Gets all the games asociated with the wishlist gameID
                        // Since MongoDB cant do inner joins this was the closest thing i could do
                        foreach (var item in items)
                        {
                            // Each item in the wishlist a search will be made that grabs the game matching its ID
                            games.Add((Game)await _customGameProxy.GetGameByID(errorMessage, item.GameID));
                        }
                        return(games);
                    }
                    else
                    {
                        return(null);
                    }
                }
                else
                {
                    // Using my delegate it will return the error message that the user must be logged in
                    errorMessage("Must be logged in");
                    return(null);
                }
            }
            else
            {
                return(null);
            }
        }
Beispiel #2
0
 // Retrieves a single game from custom API //
 public async Task <IGame> GetCustomGame(string id, HomePage.ErrorHandling errorMessage) =>
 _checkConnection.hasConnection(errorMessage) ? await _customGameProxy.GetGameByID(errorMessage, id) ?? null : null;