Ejemplo n.º 1
0
 public async Task <string> AddPost(Post post, string userId)
 {
     if (databaseOnline)
     {
         if (post != null && await cloudUserSystem.HasId(userId))
         {
             if (post.SenderId == userId)
             {
                 string newId = GetRandomId();
                 while (postList.HasPostId(newId))
                 {
                     newId = GetRandomId();
                 }
                 var    newPost = new Post(newId, post);
                 string result  = postList.AddPost(newPost);
                 if (result == null)
                 {
                     return(await cloudDatabase.AddPost(newPost));
                 }
                 return(result);
             }
         }
         return("Wrong input.");
     }
     return("Database offline");
 }
Ejemplo n.º 2
0
        public async Task <PostList> GetPostToShowByUserId(string userId)
        {
            PostList   searchList = new PostList();
            FriendList friendList = await cloudUserSystem.GetFriendListByUserId(userId);

            foreach (var post in postList.Posts)
            {
                //user's post or friends' post which is not disable user
                if (friendList.GetFriendById(post.SenderId) != null && !post.IsDisable(userId) || post.SenderId == userId)
                {
                    searchList.AddPost(post);
                }
            }
            return(searchList);
        }