Esempio n. 1
0
 public MarkRepository(PlayerContext context)
 {
     this.db = context;
 }
Esempio n. 2
0
 public PlaylistVideoRepository(PlayerContext context)
 {
 }
Esempio n. 3
0
 public SubscriptionRepository(PlayerContext context)
 {
 }
Esempio n. 4
0
 public UserRepository(PlayerContext context)
 {
 }
Esempio n. 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);
            }
        }
Esempio n. 6
0
 public WatchLaterRepository(PlayerContext context)
 {
 }
Esempio n. 7
0
 public VideoRepository(PlayerContext context)
 {
 }
Esempio n. 8
0
 public NotificationRepository(PlayerContext context)
 {
 }
Esempio n. 9
0
 public CommentRepostiroty(PlayerContext context)
 {
     this.db = context;
 }