Example #1
0
        public List <TvShowShort> GetTopTenAndSave()
        {
            var ratingList = _tvshows
                             .Find(e => e.rating > 0)
                             .SortByDescending(e => e.rating)
                             .Limit(10)
                             .ToList();

            var logPath = System.IO.Path.GetTempFileName();


            using (var writer = File.CreateText(logPath))
            {
                List <TvShowShort> rankedTvShowsList = new List <TvShowShort>();
                foreach (var item in ratingList)
                {
                    TvShowShort tvshow = new TvShowShort
                    {
                        showName    = item.name,
                        imageUrl    = item.imageUrl,
                        rating      = item.rating,
                        network     = item.network,
                        summary     = item.summary,
                        genres      = item.genres,
                        numEpisodes = item.Episodes.Count,
                    };

                    writer.WriteLine(item.name + ";" + item.network + ";" + item.Episodes.Count + "\n"); //or .Write(), if you wish
                }
                // rankedTvShowsList.Add(tvshow);
            }
            return(null);
        }
Example #2
0
        public List <TvShowShort> GetTopTen()
        {
            var ratingList = _tvshows
                             .Find(e => e.rating > 0)
                             .SortByDescending(e => e.rating)
                             .Limit(10)
                             .ToList();

            List <TvShowShort> rankedTvShowsList = new List <TvShowShort>();

            foreach (var item in ratingList)
            {
                TvShowShort tvshow = new TvShowShort
                {
                    showName    = item.name,
                    imageUrl    = item.imageUrl,
                    rating      = item.rating,
                    network     = item.network,
                    summary     = item.summary,
                    genres      = item.genres,
                    numEpisodes = item.Episodes.Count,
                };
                rankedTvShowsList.Add(tvshow);
            }
            return(rankedTvShowsList);
        }
Example #3
0
        public List <TvShowShort> GetAllShows()
        {
            var ratingList = _tvshows
                             .Find(e => true)
                             .SortByDescending(e => e.rating)
                             .ToList();

            var filterBuilder = Builders <Episode> .Filter;
            var startDate     = new DateTime(2019, 03, 25);

            List <TvShowShort> rankedTvShowsList = new List <TvShowShort>();

            foreach (var item in ratingList)
            {
                TvShowShort tvshow = new TvShowShort
                {
                    showName    = item.name,
                    imageUrl    = item.imageUrl,
                    rating      = item.rating,
                    network     = item.network,
                    summary     = item.summary,
                    genres      = item.genres,
                    numEpisodes = item.Episodes.Count,
                };

                var filter = filterBuilder.Eq(x => x.showName, item.name) &
                             filterBuilder.Lte(x => x.airdate, startDate);

                var numOfReleasedEpisodes = _episodes.Find(filter).ToList().Count;

                tvshow.numReleasedEpisodes = numOfReleasedEpisodes;

                rankedTvShowsList.Add(tvshow);
            }
            return(rankedTvShowsList);
        }