Ejemplo n.º 1
0
        public VideoWithLatest Get()
        {
            //var videos = new List<Video>();
            var youtubeOperations = new YoutubeOperations();

            var databaseInteraction = new MongoDbInteraction(new MongoDbConnection { CollectionName = "videos", DatabaseName = "StrawHatEntertainment" },
                                                             new MongoClient("mongodb://localhost"));

            var videos = databaseInteraction.FindAll<Videos>().Result;
            //var tokenInfo = BsonSerializer.Deserialize<TokenInfo>(databaseInteraction.FindAll<BsonDocument>().Result[0]);

            //youtubeOperations.GetVideoList(tokenInfo, videos);
            //var videoList = videos.Where(x => x.VideoList.Any()).ToList();
            var videoWithLatest = new VideoWithLatest();
            videoWithLatest.latestVideo = videos.Select(x => x.VideoList.OrderByDescending(y => y.PublishedDate).FirstOrDefault()).FirstOrDefault();
            videoWithLatest.videos = new List<Video>();
            foreach (var video in videos)
            {
                videoWithLatest.videos.AddRange(video.VideoList);
            }
            return videoWithLatest;
        }
Ejemplo n.º 2
0
 public UpdateVideos(IDatabaseInteraction databaseInteractions = null, YoutubeOperations youtubeOperations = null)
 {
     _youtubeOperations = youtubeOperations ?? new YoutubeOperations();
     _databaseInteraction = databaseInteractions ?? new MongoDbInteraction(new MongoDbConnection { CollectionName = "videos", DatabaseName = "StrawHatEntertainment" },
                                                      new MongoClient("mongodb://localhost"));
 }