Пример #1
0
        /// <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));
        }
Пример #2
0
 public static List <PostRendered> BindPostsContent(List <Post> posts, ClientAppType clientType)
 {
     if (clientType == ClientAppType.CfiPhone)
     {
         return(BindPostsContentForIphone(posts));
     }
     return(BindPostsContentForWeb(posts));
 }
Пример #3
0
        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());
        }
Пример #4
0
        /// <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));
        }
Пример #5
0
        /// <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);
        }
Пример #6
0
        /// <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);
        }
Пример #7
0
        /// <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;
        }
Пример #8
0
 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();
 }
Пример #9
0
        /// <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);
        }
Пример #10
0
 /// <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);
 }
Пример #11
0
        /// <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);
        }
Пример #12
0
        /// <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);
        }
Пример #13
0
        /// <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));
        }
Пример #14
0
        /// <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));
        }
Пример #15
0
        /// <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));
        }
Пример #16
0
 /// <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);
 }
Пример #17
0
 public static List<PostRendered> BindPostsContent(List<Post> posts, ClientAppType clientType)
 {
     if (clientType == ClientAppType.CfiPhone) { return BindPostsContentForIphone(posts); }
     return BindPostsContentForWeb(posts);
 }
Пример #18
0
        /// <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));
        }