示例#1
0
 public MarkRepository(PlayerContext context)
 {
     this.db = context;
 }
示例#2
0
 public PlaylistVideoRepository(PlayerContext context)
 {
 }
示例#3
0
 public SubscriptionRepository(PlayerContext context)
 {
 }
示例#4
0
 public UserRepository(PlayerContext context)
 {
 }
示例#5
0
        /// <summary>
        ///  Gets range of video start from (pageCount-1)*numberOfItems order by state, count Videos
        /// </summary>
        /// <param name="pageCount"></param>
        /// <param name="numberOfItems"></param>
        /// <param name="state"></param>
        /// <param name="searchString"></param>
        /// <param name="count"></param>
        /// <returns></returns>
        public IEnumerable <Video> GetVideoByRange(int pageCount, int numberOfItems, SortState state, string searchString, int UserId, out int count)
        {
            using (PlayerContext db = new PlayerContext())
            {
                int skip = (pageCount - 1) * numberOfItems;
                IEnumerable <Video> videos = null;
                count = db.WatchLaters.AsNoTracking().Include(x => x.Video).Where(x => x.Video.Name.Contains(searchString) && x.UserId == UserId).Count();
                switch (state)
                {
                case SortState.New:
                {
                    var temp = db.WatchLaters
                               .Where(x => x.Video.Name.Contains(searchString) && x.UserId == UserId)
                               .OrderByDescending(x => x.Video.UploadDate)
                               .Skip(skip).Take(numberOfItems).Select(x => x.Video).ToList();
                    foreach (var item in temp)
                    {
                        db.Entry(item).Reference("User").Load();
                    }
                    videos = temp;
                    break;
                }

                case SortState.Old:
                {
                    var temp = db.WatchLaters
                               .Where(x => x.Video.Name.Contains(searchString) && x.UserId == UserId)
                               .OrderBy(x => x.Video.UploadDate)
                               .Skip(skip).Take(numberOfItems).Select(x => x.Video).ToList();
                    foreach (var item in temp)
                    {
                        db.Entry(item).Reference("User").Load();
                    }
                    videos = temp;
                    break;
                }

                case SortState.Long:
                {
                    var temp = db.WatchLaters
                               .Where(x => x.Video.Name.Contains(searchString) && x.UserId == UserId)
                               .OrderByDescending(x => x.Video.MaxDuration)
                               .Skip(skip).Take(numberOfItems).Select(x => x.Video).ToList();
                    foreach (var item in temp)
                    {
                        db.Entry(item).Reference("User").Load();
                    }
                    videos = temp;
                    break;
                }

                case SortState.Short:
                {
                    var temp = db.WatchLaters
                               .Where(x => x.Video.Name.Contains(searchString) && x.UserId == UserId)
                               .OrderBy(x => x.Video.MaxDuration)
                               .Skip(skip).Take(numberOfItems).Select(x => x.Video).ToList();
                    foreach (var item in temp)
                    {
                        db.Entry(item).Reference("User").Load();
                    }
                    videos = temp;
                    break;
                }
                }
                return(videos);
            }
        }
示例#6
0
 public WatchLaterRepository(PlayerContext context)
 {
 }
示例#7
0
 public VideoRepository(PlayerContext context)
 {
 }
 public NotificationRepository(PlayerContext context)
 {
 }
示例#9
0
 public CommentRepostiroty(PlayerContext context)
 {
     this.db = context;
 }