示例#1
0
文件: UnitTest1.cs 项目: radtek/HKSJ
        public SpecialView GetUserAlbumsViews1()
        {
            int UserId  = 42;
            int albumId = 144;

            var sv = new SpecialView()
            {
                SpecialVideoList = new List <SpecialDetailView>(), SpecialCount = 0
            };

            var userSpecial = from dt in
                              (from urc in _userSpecialRepository.GetEntityList(CondtionEqualCreateUserId(UserId))
                               join uss in this._userSpecialSonRepository.GetEntityList() on urc.Id equals uss.MySpecialId into ussList
                               from usst1 in ussList.DefaultIfEmpty()
                               join video in _videoRepository.GetEntityList().Where(o => o.VideoState == 3).OrderByDescending(o => o.CreateTime) on
                               usst1 == null ? 0 : usst1.VideoId equals video.Id into videoList
                               from videot in videoList.DefaultIfEmpty()
                               orderby urc.CreateTime
                               select new
            {
                Id = urc.Id,
                Title = urc.Title,
                Image = urc.Image,
                CreateTime = urc.CreateTime,
                VideoId = videot == null ? 0 : videot.Id,
                PlayCount = videot == null ? 0 : videot.PlayCount,
                CommentCount = videot == null ? 0 : videot.CommentCount,
                SmallPicture = videot == null ? "" : videot.SmallPicturePath
            })
                              group dt by dt.Id into list
                              select new SpecialDetailView
            {
                Id           = list.Key,
                Title        = list.First().Title,
                CreateTime   = list.First().CreateTime.ToString("yyyy-MM-dd HH:mm"),
                Thumbnail    = !string.IsNullOrEmpty(list.First().Image) ? list.First().Image : list.First().SmallPicture,
                PlayCount    = list.Sum(o => o.PlayCount),
                CommentCount = list.Sum(o => o.CommentCount)
            };


            sv.SpecialCount     = userSpecial.Count();
            sv.PageCount        = GetPageCountToDataCount(sv.SpecialCount);
            sv.SpecialVideoList = userSpecial.Skip((PageIndex - 1) * PageSize).Take(PageSize).ToList();

            return(sv);
        }
示例#2
0
        /// <summary>
        /// 获取用户创建的专辑,过滤已添加到空间专辑
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <param name="escapeStatestate"></param>
        /// <returns></returns>
        public SpecialView GetUserAlbumsViews(int userId, int pageIndex, int pageSize)
        {
            var sv = new SpecialView()
            {
                SpecialVideoList = new List <SpecialDetailView>(), SpecialCount = 0
            };

            var userSpecial = (from urc in _userSpecialRepository.GetEntityList(CondtionEqualCreateUserId(userId))
                               where !(from userroomchoose in this._userRoomChooseRepository.GetEntityList(CondtionEqualUserId(userId))
                                       where
                                       userroomchoose.TypeId == 1
                                       select new
            {
                userroomchoose.ModuleId
            }).Contains(new { ModuleId = urc.Id })
                               select urc
                               ).AsQueryable();
            List <UserSpecial> list = userSpecial.ToList <UserSpecial>();

            List <SpecialDetailView> sdvList = new List <SpecialDetailView>();
            SpecialDetailView        sdv     = null;

            List <SpecialVideoView> svvList   = new List <SpecialVideoView>();
            SpecialVideoView        svv       = null;
            List <Video>            videoList = null;



            foreach (UserSpecial item in list)
            {
                sdv       = new SpecialDetailView();
                sdv.Id    = item.Id;
                sdv.Title = item.Title;

                var vidoes = (from ussl in this._userSpecialSonRepository.GetEntityList(CondtionEqualSpecialId(item.Id))
                              join video in this._videoRepository.GetEntityList(CondtionEqualState()) on(long) ussl.VideoId equals video.Id
                              where video.VideoState == 3 //TODO update 刘强2015-11-06 过滤审核状态
                              select video
                              ).AsQueryable();
                videoList = vidoes.ToList <Video>();
                foreach (Video v in videoList)
                {
                    svv    = new SpecialVideoView();
                    svv.Id = v.Id;
                    svv.SmallPicturePath = v.SmallPicturePath;
                    svv.Title            = v.Title;
                    svv.PlayCount        = v.PlayCount;
                    svv.CommentCount     = v.CommentCount;
                    svv.TimeLength       = ConvertUtil.ToInt(v.TimeLength, 0);
                    svvList.Add(svv);
                }


                sdv.SpecialVideoList = svvList;
                sdvList.Add(sdv);
            }
            sv.SpecialVideoList = sdvList;

            if (list.Count <= 0)
            {
                return(sv);
            }
            sv.SpecialCount     = list.Count;
            sv.PageCount        = sv.SpecialCount % pageSize == 0 ? sv.SpecialCount / pageSize : sv.SpecialCount / pageSize + 1;
            sv.SpecialVideoList = sv.SpecialVideoList.Skip((pageIndex - 1) * pageSize).Take(pageSize).ToList();
            return(sv);
        }