Esempio n. 1
0
        /// <summary>
        ///  精选——评论列表
        /// </summary>
        /// <param name="videoId">视频编号</param>
        /// <param name="pageSize">显示多少行</param>
        /// <param name="pageIndex">显示第几页</param>
        /// <returns></returns>
        public AppComments VideoComments(int videoId, int pageSize, int pageIndex)
        {
            AppComments videoComment = new AppComments()
            {
                TotalCount = 0,
                Comments   = new List <AppCommentsView>()
            };

            if (IsExistVideo(videoId))
            {
                IQueryable <AppCommentView> comments = (from c in this._commentsRepository.GetEntityList()
                                                        join v in this._videoRepository.GetEntityList(CondtionEqualState()) on c.EntityId equals v.Id
                                                        join u in this._userRepository.GetEntityList(CondtionEqualState()) on v.CreateManageId equals u.Id
                                                        join fu in this._userRepository.GetEntityList(CondtionEqualState()) on c.FromUserId equals fu.Id
                                                        join tu in this._userRepository.GetEntityList(CondtionEqualState()) on c.ToUserId equals tu.Id
                                                        into tuJoin
                                                        from toUser in tuJoin.DefaultIfEmpty()
                                                        orderby c.CreateTime descending
                                                        where c.State >= 0 &&
                                                        c.EntityType == (int)CommentEnum.Video &&
                                                        c.EntityId == videoId &&
                                                        c.ParentId == 0 &&
                                                        v.VideoState == 3 &&
                                                        v.VideoSource
                                                        select CommentView(c, fu, u));//不要视频信息和接收用户信息
                videoComment.TotalCount = comments.Count();
                var data = PageList(comments, pageSize, pageIndex);
                foreach (var parentCommnet in data)
                {
                    AppCommentsView commentView = new AppCommentsView()
                    {
                        ParentComment = parentCommnet,
                        ChildComments = (from c in this._commentsRepository.GetEntityList()
                                         join v in this._videoRepository.GetEntityList(CondtionEqualState()) on c.EntityId equals v.Id
                                         join u in this._userRepository.GetEntityList(CondtionEqualState()) on v.CreateManageId equals u.Id
                                         join fu in this._userRepository.GetEntityList(CondtionEqualState()) on c.FromUserId equals fu.Id
                                         join tu in this._userRepository.GetEntityList(CondtionEqualState()) on c.ToUserId equals tu.Id
                                         orderby c.CreateTime descending
                                         where c.State >= 0 &&
                                         c.EntityType == (int)CommentEnum.Video &&
                                         c.EntityId == videoId &&
                                         c.LocalPath.StartsWith(parentCommnet.LocalPath) &&
                                         v.VideoState == 3 &&
                                         v.VideoSource
                                         select CommentView(c, fu, u)).Take(2).ToList()
                    };
                    videoComment.Comments.Add(commentView);
                }
            }
            return(videoComment);
        }
Esempio n. 2
0
        /// <summary>
        ///  精选--评论列表详情
        /// </summary>
        /// <param name="videoId">视频编号</param>
        /// <param name="pid">发表评论的编号</param>
        /// <param name="pageSize">显示多少行</param>
        /// <param name="pageIndex">显示第几页</param>
        /// <returns></returns>
        public AppCommentsView VideoComments(int videoId, int pid, int pageSize, int pageIndex)
        {
            AppCommentsView videoComment = new AppCommentsView()
            {
                ParentComment = new AppCommentView(),
                ChildComments = new List <AppCommentView>()
            };

            if (IsExistVideo(videoId))
            {
                var parentComment = (from c in this._commentsRepository.GetEntityList()
                                     join v in this._videoRepository.GetEntityList(CondtionEqualState()) on c.EntityId equals v.Id
                                     join u in this._userRepository.GetEntityList(CondtionEqualState()) on v.CreateManageId equals u.Id
                                     join fu in this._userRepository.GetEntityList(CondtionEqualState()) on c.FromUserId equals fu.Id
                                     join tu in this._userRepository.GetEntityList(CondtionEqualState()) on c.ToUserId equals tu.Id
                                     into tuJoin
                                     from toUser in tuJoin.DefaultIfEmpty()
                                     orderby c.CreateTime descending
                                     where c.State >= 0 &&
                                     c.EntityType == (int)CommentEnum.Video &&
                                     c.EntityId == videoId &&
                                     c.ParentId == 0 &&
                                     c.Id == pid &&
                                     v.VideoState == 3 &&
                                     v.VideoSource
                                     select CommentView(c, fu, u)).FirstOrDefault();
                if (parentComment != null)
                {
                    videoComment.ParentComment = parentComment;
                    IQueryable <AppCommentView> comments = (from c in this._commentsRepository.GetEntityList()
                                                            join v in this._videoRepository.GetEntityList(CondtionEqualState()) on c.EntityId equals v.Id
                                                            join u in this._userRepository.GetEntityList(CondtionEqualState()) on v.CreateManageId equals u.Id
                                                            join fu in this._userRepository.GetEntityList(CondtionEqualState()) on c.FromUserId equals fu.Id
                                                            join tu in this._userRepository.GetEntityList(CondtionEqualState()) on c.ToUserId equals tu.Id
                                                            into tuJoin
                                                            from toUser in tuJoin.DefaultIfEmpty()
                                                            orderby c.CreateTime descending
                                                            where c.State >= 0 &&
                                                            c.EntityType == (int)CommentEnum.Video &&
                                                            c.EntityId == videoId &&
                                                            c.LocalPath.StartsWith(parentComment.LocalPath) &&
                                                            v.VideoState == 3 &&
                                                            v.VideoSource
                                                            select CommentView(c, fu, u));
                    videoComment.ChildComments = PageList(comments, pageSize, pageIndex);
                }
            }
            return(videoComment);
        }
Esempio n. 3
0
        /// <summary>
        ///  精选——评论列表
        /// </summary>
        /// <param name="userId">登录用户编号或者浏览用户编号</param>
        /// <param name="pageSize">显示多少行</param>
        /// <param name="pageIndex">显示第几页</param>
        /// <returns></returns>
        public AppComments SpaceComments(int userId, int pageSize, int pageIndex)
        {
            AppComments spaceComment = new AppComments()
            {
                TotalCount = 0,
                Comments   = new List <AppCommentsView>()
            };

            if (userId > 0)
            {
                IQueryable <AppCommentView> comments = (from c in this._commentsRepository.GetEntityList()
                                                        join u in this._userRepository.GetEntityList(CondtionEqualState()) on c.EntityId equals u.Id
                                                        join fu in this._userRepository.GetEntityList(CondtionEqualState()) on c.FromUserId equals fu.Id
                                                        join tu in this._userRepository.GetEntityList(CondtionEqualState()) on c.ToUserId equals tu.Id
                                                        into tuJoin
                                                        from toUser in tuJoin.DefaultIfEmpty()
                                                        orderby c.CreateTime descending
                                                        where c.State >= (int)CommentStateEnum.Waiting &&
                                                        c.EntityType == (int)CommentEnum.User &&
                                                        c.EntityId == userId &&
                                                        c.ParentId == 0
                                                        select CommentView(c, fu, u)); //不要视频信息和接收用户信息
                spaceComment.TotalCount = comments.Count();
                var data = PageList(comments, pageSize, pageIndex);
                foreach (var parentCommnet in data)
                {
                    AppCommentsView commentView = new AppCommentsView()
                    {
                        ParentComment = parentCommnet,
                        ChildComments = (from c in this._commentsRepository.GetEntityList()
                                         join u in this._userRepository.GetEntityList(CondtionEqualState()) on c.EntityId equals
                                         u.Id
                                         join fu in this._userRepository.GetEntityList(CondtionEqualState()) on c.FromUserId
                                         equals fu.Id
                                         join tu in this._userRepository.GetEntityList(CondtionEqualState()) on c.ToUserId equals
                                         tu.Id
                                         orderby c.CreateTime descending
                                         where c.State >= (int)CommentStateEnum.Waiting &&
                                         c.EntityType == (int)CommentEnum.User &&
                                         c.EntityId == userId &&
                                         c.LocalPath.StartsWith(parentCommnet.LocalPath)
                                         select CommentView(c, fu, u)).Take(2).ToList()
                    };
                    spaceComment.Comments.Add(commentView);
                }
            }
            return(spaceComment);
        }