public IHttpActionResult RecommendedPosts([FromUri] string AccessToken) { var UserId = TokenValidator.VerifyToken(AccessToken); var UserFollows = UserAuxiliar .Follows(UserId, SQLContext) .Select(x => x.Id); var UserTopics = UserAuxiliar.FollowedSubjects(UserId, SQLContext); var UserPosts = PostAuxiliar.PostsByAuthor(UserId); var UserMentionPosts = PostAuxiliar.MentionsUser(UserId, SQLContext); var FollowsPosts = PostAuxiliar.PostsByAuthors(UserFollows); var FollowsMentionPosts = PostAuxiliar.MentionsUsers(UserFollows); var TopicsPosts = PostAuxiliar.PostsBySubjects(UserTopics.Select(x => x.Id)); var PostComparer = new PostComparer(); var RecommendedPosts = UserPosts .Union(UserMentionPosts, PostComparer) .Union(FollowsPosts, PostComparer) .Union(FollowsMentionPosts, PostComparer) .Union(TopicsPosts, PostComparer) .ToList(); RecommendedPosts = PostAuxiliar.UpdateOwner(RecommendedPosts, SQLContext); RecommendedPosts = GraphAuxiliar.OrderPostsByAffinity(UserId, RecommendedPosts, SQLContext); return(Ok(RecommendedPosts)); }
public IHttpActionResult PostsByUser([FromUri] int UserId) { var Posts = PostAuxiliar.PostsByAuthor(UserId); Posts = PostAuxiliar.UpdateOwner(Posts, SQLContext); var MentionsPosts = PostAuxiliar.MentionsUser(UserId, SQLContext); var Response = Posts.Union(MentionsPosts, new PostComparer()).ToList(); return(Ok(Response)); }