public static ContentStreamViewModel GetContentStreamAsNewsfeed(string ownerKey, string viewerKey) { ContentStream retrievedWall = PublishingRepository.GetContentStreamAsNewsfeed(new Guid(ownerKey)); ContentStreamViewModel result = new ContentStreamViewModel(); result.Posts = new List<PostViewModel>(); result.Tweets = new List<TweetViewModel>(); result.Retweets = new List<RetweetViewModel>(); foreach (Post post in retrievedWall.Posts) { PostViewModel thisPost = new PostViewModel(); thisPost.Key = post.Key.ToString(); thisPost.Text = post.Text; //thisPost.AuthorKey = post.Author.ReferenceKey.ToString(); //thisPost.AuthorName = SecurityRepository.GetCompleteProfile(post.Author.ReferenceKey); var postAuthorProfile = SecurityRepository.GetCompleteProfile(post.Author); thisPost.Author = new CompleteProfileViewModel { BasicProfile = new BasicProfileViewModel { ReferenceKey = postAuthorProfile.BasicProfile.ReferenceKey.ToString(), AccountType = post.Author.ReferenceType }, FullName = postAuthorProfile.FullName, Description1 = postAuthorProfile.Description1, Description2 = postAuthorProfile.Description2 }; thisPost.PublishDateTime = post.PublishDateTime; thisPost.Comments = new List<CommentViewModel>(); if (post.PostLikes != null) { thisPost.Likes = post.PostLikes.Count(); var myLikeValueOnThisPost = post.PostLikes.FirstOrDefault(x => x.Author.ReferenceKey.ToString() == viewerKey); if (myLikeValueOnThisPost != null) { thisPost.ILikedIt = true; } else { thisPost.ILikedIt = false; } } else { thisPost.Likes = 0; } thisPost.Likes = post.PostLikes.Count(); foreach (Comment comment in post.Comments) { CommentViewModel thisComment = new CommentViewModel(); thisComment.Key = comment.Key.ToString(); thisComment.Text = comment.Text; //thisComment.AuthorKey = comment.Author.ReferenceKey.ToString(); //thisComment.AuthorName = SecurityRepository.GetCompleteProfile(comment.Author.ReferenceKey); var commentAuthorProfile = SecurityRepository.GetCompleteProfile(comment.Author); thisComment.Author = new CompleteProfileViewModel { BasicProfile = new BasicProfileViewModel { ReferenceKey = commentAuthorProfile.BasicProfile.ReferenceKey.ToString(), AccountType = commentAuthorProfile.BasicProfile.ReferenceType }, FullName = commentAuthorProfile.FullName, Description1 = commentAuthorProfile.Description1, Description2 = commentAuthorProfile.Description2 }; thisComment.PublishDateTime = comment.PublishDateTime; if (comment.CommentLikes != null) { thisComment.Likes = comment.CommentLikes.Count; var myLikeValueOnThisComment = comment.CommentLikes.FirstOrDefault(x => x.Author.ReferenceKey.ToString() == viewerKey); if (myLikeValueOnThisComment != null) { thisComment.ILikedIt = true; } else { thisComment.ILikedIt = false; } } // thisComment.Likes = comment.CommentLikes.Count(); thisPost.Comments.Add(thisComment); } result.Posts.Add(thisPost); } foreach (Tweet tweet in retrievedWall.Tweets) { TweetViewModel thisTweet = new TweetViewModel(); thisTweet.Key = tweet.Key.ToString(); thisTweet.Text = tweet.Text; thisTweet.PublishDateTime = tweet.PublishDateTime; var tweetAuthorProfile = SecurityRepository.GetCompleteProfile(tweet.Author); thisTweet.Author = new CompleteProfileViewModel { BasicProfile = new BasicProfileViewModel { ReferenceKey = tweetAuthorProfile.BasicProfile.ReferenceKey.ToString(), AccountType = tweet.Author.ReferenceType }, FullName = tweetAuthorProfile.FullName, Description1 = tweetAuthorProfile.Description1, Description2 = tweetAuthorProfile.Description2 }; thisTweet.Retweets = 0; result.Tweets.Add(thisTweet); } foreach (Retweet retweet in retrievedWall.Retweets) { RetweetViewModel thisRetweet = new RetweetViewModel(); var tweetAuthorProfile = SecurityRepository.GetCompleteProfile(retweet.Tweet.Author); var retweetAuthorProfile = SecurityRepository.GetCompleteProfile(retweet.Author); thisRetweet.TweetAuthor = new CompleteProfileViewModel { BasicProfile = new BasicProfileViewModel { ReferenceKey = tweetAuthorProfile.BasicProfile.ReferenceKey.ToString(), AccountType = retweet.Tweet.Author.ReferenceType }, FullName = tweetAuthorProfile.FullName, Description1 = tweetAuthorProfile.Description1, Description2 = tweetAuthorProfile.Description2 }; thisRetweet.RetweetAuthor = new CompleteProfileViewModel { BasicProfile = new BasicProfileViewModel { ReferenceKey = retweetAuthorProfile.BasicProfile.ReferenceKey.ToString(), AccountType = retweet.Author.ReferenceType }, FullName = retweetAuthorProfile.FullName, Description1 = retweetAuthorProfile.Description1, Description2 = retweetAuthorProfile.Description2 }; thisRetweet.Text = retweet.Tweet.Text; thisRetweet.RetweetKey = retweet.Key.ToString(); thisRetweet.TweetKey = retweet.Tweet.Key.ToString(); thisRetweet.TweetPublishDateTime = retweet.Tweet.PublishDateTime; thisRetweet.PublishDateTime = retweet.PublishDateTime; result.Retweets.Add(thisRetweet); } return result; }
public static RetweetViewModel GetRetweet(string retweetKey) { Retweet retrievedRetweet = PublishingRepository.GetRetweet(new Guid(retweetKey)); RetweetViewModel newRetweet = new RetweetViewModel(); newRetweet.RetweetKey = retrievedRetweet.Key.ToString(); newRetweet.TweetKey = retrievedRetweet.Tweet.Key.ToString(); var tweetAuthorProfile = SecurityRepository.GetCompleteProfile(retrievedRetweet.Tweet.Author); newRetweet.TweetAuthor = new CompleteProfileViewModel { BasicProfile = new BasicProfileViewModel { ReferenceKey = tweetAuthorProfile.BasicProfile.ReferenceKey.ToString(), AccountType = tweetAuthorProfile.BasicProfile.ReferenceType }, FullName = tweetAuthorProfile.FullName, Description1 = tweetAuthorProfile.Description1, Description2 = tweetAuthorProfile.Description2 }; newRetweet.Text = retrievedRetweet.Tweet.Text; newRetweet.PublishDateTime = retrievedRetweet.PublishDateTime; var retweetAuthorProfile = SecurityRepository.GetCompleteProfile(retrievedRetweet.Author); newRetweet.RetweetAuthor = new CompleteProfileViewModel { BasicProfile = new BasicProfileViewModel { ReferenceKey = retweetAuthorProfile.BasicProfile.ReferenceKey.ToString(), AccountType = retweetAuthorProfile.BasicProfile.ReferenceType }, FullName = retweetAuthorProfile.FullName, Description1 = retweetAuthorProfile.Description1, Description2 = retweetAuthorProfile.Description2 }; newRetweet.TweetPublishDateTime = retrievedRetweet.Tweet.PublishDateTime; return newRetweet; }