Example #1
0
        /// <summary>
        /// Insert a friend into a users friends list
        /// </summary>
        /// <param name="iFriend">The friend to insert to the friends list, created by FriendsList.AddFriend</param>
        /// <returns>True if the friend was inserted successfully</returns>
        public Boolean InsertFriendIntoFriendsList(Friend iFriend)
        {
            Boolean        pBlnCreatedTable = cCTeFriendsLists.CreateIfNotExists();
            TableOperation pTOnInsert       = TableOperation.Insert(iFriend);
            TableResult    pTRtResult;

            try
            {
                pTRtResult = FriendsListTable.Execute(pTOnInsert);
                switch (pTRtResult.HttpStatusCode)
                {
                case 200:
                case 204:
                {
                    return(true);
                }

                default:
                {
                    return(false);
                }
                }
            }
            catch
            {
                return(false);
            }
        }
Example #2
0
        public Boolean DeleteFriendFromUsersFriendList(Friend iFriend)
        {
            Boolean pBlnCreatedTable = cCTeFriendsLists.CreateIfNotExists();

            if (pBlnCreatedTable)
            {
                return(false);
            }
            else
            {
                TableOperation pTOnDelete = TableOperation.Delete(iFriend);
                TableResult    pTRtResult;
                try
                {
                    pTRtResult = FriendsListTable.Execute(pTOnDelete);
                    switch (pTRtResult.HttpStatusCode)
                    {
                    case 200:
                    case 204:
                    {
                        return(true);
                    }

                    default:
                    {
                        return(false);
                    }
                    }
                }
                catch
                {
                    return(false);
                }
            }
        }
Example #3
0
        /// <summary>
        /// Get the friends list of a specific user
        /// </summary>
        /// <param name="iUser">The user to get the friends list for</param>
        /// <returns>The friends list of the provided user</returns>
        public FriendsList GetUserFriendsList(User iUser)
        {
            Boolean pBlnCreatedTable = cCTeFriendsLists.CreateIfNotExists();

            if (pBlnCreatedTable)
            {
                FriendsList pFLtFriends = new FriendsList(iUser, new List <Friend>());
                return(pFLtFriends);
            }
            else
            {
                String pStrPartitionKey = iUser.RowKey;
                String pStrFilter       = TableQuery.GenerateFilterCondition(
                    "PartitionKey",
                    QueryComparisons.Equal,
                    pStrPartitionKey);

                TableQuery <Friend>  pTQyQuery   = new TableQuery <Friend>().Where(pStrFilter);
                IEnumerable <Friend> pIEeMatches = FriendsListTable.ExecuteQuery <Friend>(pTQyQuery);
                List <Friend>        pLisMatches = new List <Friend>(pIEeMatches);

                FriendsList pFLtFriends = new FriendsList(iUser, pLisMatches);
                return(pFLtFriends);
            }
        }