コード例 #1
0
        public object GetUserFeed(int userId, int p, int n)
        {
            var feed = Follows
                       .Where(f => f.FollowerId == userId)
                       .Select(f => Posts.Where(pt => pt.AuthorId == f.FollowedId).ToList())
                       .SelectMany(pt => pt)
                       .OrderByDescending(pt => pt.Published)
                       .ToList()
                       .Select(pt => GetFormattedPost(pt))
                       .ToList();

            return(n < feed.Count - p ?
                   feed.GetRange(p, n) :
                   (feed.Count - p > 0 ?
                    feed.GetRange(p, feed.Count - p) :
                    new List <object> ()));
        }
コード例 #2
0
 public int GetFollowerCount(int id)
 {
     return(Follows.Where(f => f.FollowedId == id).Count());
 }
コード例 #3
0
 public ICollection <int> GetFolloweds(int id)
 {
     return(Follows.Where(f => f.FollowerId == id).Select(f => f.FollowedId).ToList());
 }