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> ())); }
public int GetFollowerCount(int id) { return(Follows.Where(f => f.FollowedId == id).Count()); }
public ICollection <int> GetFolloweds(int id) { return(Follows.Where(f => f.FollowerId == id).Select(f => f.FollowedId).ToList()); }