Beispiel #1
0
        //public static List<Post> GetUserPostsOnly(BackofficeUnitOfWork context, string Id)
        //{
        //    List<long> hiddenPostIds = context.PostHidden
        //        .Fetch()
        //        .Where(i => i.ID_User == Id && i.Hidden)
        //        .Select(i => i.ID_Post)
        //        .ToList();

        //    List<Post> postList = context.Post
        //        .Fetch()
        //        .Include(i => i.AspNetUsers.Profile)
        //        .Include(i => i.PostType)
        //        .Include(i => i.PostSubject)
        //        .Include(i => i.PostLike)
        //        .Include(i => i.PostComment)
        //        .Include(i => i.PostHidden)
        //        //.Include(i => i.ChatMessage.OrderByDescending(j => j.CreateDate).Take(20))
        //        .Include(i => i.PostImage)
        //        .Where(i => i.ID_User == Id
        //            && i.Active
        //            && !hiddenPostIds.Contains(i.ID)
        //            && (
        //                i.PostSubject.Token.Equals("PERSONAL_POST")
        //                || i.PostSubject.Token.Equals("BUSINESS_POST")
        //                || i.PostSubject.Token.Equals("NEWS_POST")
        //                || i.PostSubject.Token.Equals("PARTNERSHIP_POST")
        //                || i.PostSubject.Token.Equals("WALLET_POST")
        //                || i.PostSubject.Token.Equals("SPONSORED_POST")
        //                || i.PostSubject.Token.Equals("GLOBAL_POST")
        //            ))
        //        .OrderByDescending(i => i.Sticky)
        //        .ThenByDescending(i => i.CreateDate)
        //        .ToList();

        //    postList.ForEach(p => p.PostComment = p.PostComment.Where(c => c.Active).Select(c => c).OrderBy(i => i.Date).ToList());
        //    postList.ForEach(p => p.PostLike = p.PostLike.Where(c => c.Active).Select(c => c).ToList());
        //    postList.ForEach(p => p.PostImage = p.PostImage.Where(c => c.Active).Select(c => c).ToList());

        //    return postList;
        //}

        public static List <Post> GetPosts(BackofficeUnitOfWork context, string Id, PostSubjectEnum postSubject)
        {
            List <long> hiddenPostIds = context.PostHidden
                                        .Fetch()
                                        .Where(i => i.ID_User == Id && i.Hidden)
                                        .Select(i => i.ID_Post)
                                        .ToList();

            List <Post> postList = context.Post
                                   .Fetch()
                                   .Include(i => i.AspNetUsers.Profile)
                                   .Include(i => i.PostType)
                                   .Include(i => i.PostSubject)
                                   .Include(i => i.PostLike)
                                   .Include(i => i.PostComment)
                                   .Include(i => i.PostHidden)
                                   .Include(i => i.PostImage)
                                   .Include(i => i.District)
                                   .Include(i => i.County)
                                   .Where(i => i.PostSubject.Token.Equals(postSubject.ToString()) &&
                                          i.Active &&
                                          !hiddenPostIds.Contains(i.ID)
                                          )
                                   .OrderByDescending(i => i.Sticky)
                                   .ThenByDescending(i => i.CreateDate)
                                   .ToList();

            postList.ForEach(p => p.PostComment = p.PostComment.Where(c => c.Active).Select(c => c).OrderBy(i => i.Date).ToList());
            postList.ForEach(p => p.PostImage   = p.PostImage.Where(c => c.Active).Select(c => c).ToList());

            return(postList);
        }
Beispiel #2
0
        public static List <Post> GetPostsBySubject(BackofficeUnitOfWork context, PostSubjectEnum postSubject)
        {
            List <Post> postList = context.Post
                                   .Fetch()
                                   .Include(i => i.AspNetUsers.Profile)
                                   .Include(i => i.PostType)
                                   .Include(i => i.PostSubject)
                                   .Include(i => i.PostLike)
                                   .Include(i => i.PostComment)
                                   .Include(i => i.PostImage)
                                   .Where(i => i.PostSubject.Token == postSubject.ToString() &&
                                          i.Active)
                                   .OrderByDescending(i => i.Sticky)
                                   .ThenByDescending(i => i.CreateDate)
                                   .ToList();

            postList.ForEach(p => p.PostComment = p.PostComment.Where(c => c.Active).Select(c => c).OrderBy(i => i.Date).ToList());
            postList.ForEach(p => p.PostImage   = p.PostImage.Where(c => c.Active).Select(c => c).ToList());

            return(postList);
        }