/// <summary> /// Select feed post relevant to an area /// </summary> /// <param name="locationID"></param> /// <param name="clientType"></param> /// <returns></returns> public List <PostRendered> GetPostForArea(Guid areaID, PostType postType, ClientAppType clientType) { var feedPlaces = GetGeoDeducPlaces(new List <Guid> { areaID }); return(GetPostsForPlaces(feedPlaces, postType, clientType)); }
public static List <PostRendered> BindPostsContent(List <Post> posts, ClientAppType clientType) { if (clientType == ClientAppType.CfiPhone) { return(BindPostsContentForIphone(posts)); } return(BindPostsContentForWeb(posts)); }
public PostRendered GetPostRenderedByID(Guid id, ClientAppType clientType) { var post = postRepo.GetPostsInclude().Where(p => p.ID == id).SingleOrDefault(); var postsRendered = ContentRenderer.BindPostsContent(new List <Post>() { post }, clientType); return(postsRendered.First()); }
/// <summary> /// Basically the latest posts on the whole site/mobile /// </summary> public List <PostRendered> GetPostForEverywhere(PostType type, ClientAppType clientType) { var query = postRepo.GetPostsInclude().Where(p => p.IsPublic).OrderByDescending(c => c.LastActivityUtc).Take(ResultsPostCount); if (type != PostType.Unknown) { query = query.Where(p => p.TypeID == (int)type); } return(ContentRenderer.BindPostsContent(query.ToList(), clientType)); }
/// <summary> /// Select feed posts relevant to the users preferences PLUS their feed places and return as a FeedResultSet /// </summary> /// <param name="userID"></param> /// <returns></returns> public FeedResultSet GetUsersFeed(Guid userID, PostType postType, ClientAppType clientType) { var result = new FeedResultSet(); //-- These are the preferences WITHOUT dedec places (don't want deduc in the filters down the left) var userPlacePreferences = (from c in new ProfileRepository().GetFeedPlacePreferences(userID) where AppLookups.GetCacheIndexEntry(c) != null select AppLookups.GetCacheIndexEntry(c)).ToList(); result.Places = userPlacePreferences; //-- For the actual feed posts we use deduc var feedPlaces = GetGeoDeducPlaces(userPlacePreferences.Select(p => p.ID)); result.Posts = GetPostsForPlaces(feedPlaces, postType, clientType); return(result); }
/// <summary> /// Underlying helper /// </summary> /// <param name="places"></param> /// <param name="postType"></param> /// <param name="clientType"></param> /// <returns></returns> private List<PostRendered> GetPostsForPlaces(List<CfCacheIndexEntry> places, PostType postType, ClientAppType clientType) { if (places.Count == 0) { return GetPostForEverywhere(postType, clientType); } var feedPlaceIDs = places.Select(p => p.ID).Distinct().ToList(); IQueryable<Post> query = postRepo.GetPostsInclude() .Where(c => c.IsPublic && feedPlaceIDs.Contains(c.PlaceID)) .OrderByDescending(c => c.LastActivityUtc) .Take(ResultsPostCount); if (postType != PostType.Unknown) { query = query.Where(p => p.TypeID == (int)postType); } return ContentRenderer.BindPostsContent(query.ToList(), clientType); }
/// <summary> /// Select feed posts relevant to the users preferences PLUS their feed places and return as a FeedResultSet /// </summary> /// <param name="userID"></param> /// <returns></returns> public FeedResultSet GetUsersFeed(Guid userID, PostType postType, ClientAppType clientType) { var result = new FeedResultSet(); //-- These are the preferences WITHOUT dedec places (don't want deduc in the filters down the left) var userPlacePreferences = (from c in new ProfileRepository().GetFeedPlacePreferences(userID) where AppLookups.GetCacheIndexEntry(c) != null select AppLookups.GetCacheIndexEntry(c)).ToList(); result.Places = userPlacePreferences; //-- For the actual feed posts we use deduc var feedPlaces = GetGeoDeducPlaces(userPlacePreferences.Select(p => p.ID)); result.Posts = GetPostsForPlaces(feedPlaces, postType, clientType); return result; }
public PostRendered GetPostRenderedByID(Guid id, ClientAppType clientType) { var post = postRepo.GetPostsInclude().Where(p=>p.ID == id).SingleOrDefault(); var postsRendered = ContentRenderer.BindPostsContent(new List<Post>() {post }, clientType); return postsRendered.First(); }
/// <summary> /// Select feed post made by a single user /// </summary> /// <param name="locationID"></param> /// <param name="clientType"></param> /// <returns></returns> public List<PostRendered> GetPostForUser(Guid userID, ClientAppType clientType, int count) { var posts = postRepo.GetAll().Where(p => p.UserID == userID).OrderByDescending(p => p.Utc).Take(count).ToList(); return ContentRenderer.BindPostsContent(posts,clientType); }
/// <summary> /// Select feed post relevant to a single location (and NO deduc places) /// </summary> public List<PostRendered> GetPostForLocation(Guid locationID, PostType postType, ClientAppType clientType) { var feedPlaces = new List<CfCacheIndexEntry>() { CfCacheIndex.Get(locationID) }; return GetPostsForPlaces(feedPlaces, postType, clientType); }
/// <summary> /// Basically the latest posts on the whole site/mobile /// </summary> public List<PostRendered> GetPostForEverywhere(PostType type, ClientAppType clientType) { var query = postRepo.GetPostsInclude().Where(p => p.IsPublic).OrderByDescending(c => c.LastActivityUtc).Take(ResultsPostCount); if (type != PostType.Unknown) { query = query.Where(p => p.TypeID == (int)type); } return ContentRenderer.BindPostsContent(query.ToList(), clientType); }
/// <summary> /// Select feed posts relevant to the users current geo-context /// </summary> public List<PostRendered> GetGeoFeed(double lat, double lon, PostType postType, ClientAppType clientType) { var intersectingAreas = new AreaRepository().GetIntersectingAreasOfPoint(lat, lon).ToList(); var feedPlaces = GetGeoDeducPlaces(intersectingAreas.Select(p => p.ID)); if (feedPlaces.Count < 2) { feedPlaces.AddRange(from p in new MobileSvcRepository().GetNearestLocationsV0(lat, lon, 4) select CfCacheIndex.Get(p.ID)); } return GetPostsForPlaces(feedPlaces, postType, clientType); }
/// <summary> /// Select feed posts relevant to the users current geo-context /// </summary> public List <PostRendered> GetGeoFeed(double lat, double lon, PostType postType, ClientAppType clientType) { var intersectingAreas = new AreaRepository().GetIntersectingAreasOfPoint(lat, lon).ToList(); var feedPlaces = GetGeoDeducPlaces(intersectingAreas.Select(p => p.ID)); if (feedPlaces.Count < 2) { feedPlaces.AddRange(from p in new MobileSvcRepository().GetNearestLocationsV0(lat, lon, 4) select CfCacheIndex.Get(p.ID)); } return(GetPostsForPlaces(feedPlaces, postType, clientType)); }
/// <summary> /// Select feed post made by a single user /// </summary> /// <param name="locationID"></param> /// <param name="clientType"></param> /// <returns></returns> public List <PostRendered> GetPostForUser(Guid userID, ClientAppType clientType, int count) { var posts = postRepo.GetAll().Where(p => p.UserID == userID).OrderByDescending(p => p.Utc).Take(count).ToList(); return(ContentRenderer.BindPostsContent(posts, clientType)); }
/// <summary> /// Underlying helper /// </summary> /// <param name="places"></param> /// <param name="postType"></param> /// <param name="clientType"></param> /// <returns></returns> private List <PostRendered> GetPostsForPlaces(List <CfCacheIndexEntry> places, PostType postType, ClientAppType clientType) { if (places.Count == 0) { return(GetPostForEverywhere(postType, clientType)); } var feedPlaceIDs = places.Select(p => p.ID).Distinct().ToList(); IQueryable <Post> query = postRepo.GetPostsInclude() .Where(c => c.IsPublic && feedPlaceIDs.Contains(c.PlaceID)) .OrderByDescending(c => c.LastActivityUtc) .Take(ResultsPostCount); if (postType != PostType.Unknown) { query = query.Where(p => p.TypeID == (int)postType); } return(ContentRenderer.BindPostsContent(query.ToList(), clientType)); }
/// <summary> /// Select feed post relevant to an area /// </summary> /// <param name="locationID"></param> /// <param name="clientType"></param> /// <returns></returns> public List<PostRendered> GetPostForArea(Guid areaID, PostType postType, ClientAppType clientType) { var feedPlaces = GetGeoDeducPlaces(new List<Guid> { areaID}); return GetPostsForPlaces(feedPlaces, postType, clientType); }
public static List<PostRendered> BindPostsContent(List<Post> posts, ClientAppType clientType) { if (clientType == ClientAppType.CfiPhone) { return BindPostsContentForIphone(posts); } return BindPostsContentForWeb(posts); }
/// <summary> /// Select feed post relevant to a single location (and NO deduc places) /// </summary> public List <PostRendered> GetPostForLocation(Guid locationID, PostType postType, ClientAppType clientType) { var feedPlaces = new List <CfCacheIndexEntry>() { CfCacheIndex.Get(locationID) }; return(GetPostsForPlaces(feedPlaces, postType, clientType)); }