Exemple #1
0
        private async Task GetMovieGenres(Movie movie)
        {
            var relationRepository = new RelationRepository(Configuration, MemoryCache);

            var isExist = MemoryCache.TryGetValue("CACHEMOVIERELATIONS" + movie.GetId(), out List <Relation> movieRelations);

            if (!isExist)
            {
                movieRelations = await relationRepository.GetRelationsByParent(
                    movie.GetEntityCategoryId(), movie.GetId());

                MemoryCache.Set("CACHEMOVIERELATIONS" + movie.GetId(), movieRelations);
                TrakkerCache.SaveCacheEntry("CACHEMOVIERELATIONS" + movie.GetId());
            }

            var movieGenreRepository = new MovieGenreRepository(Configuration, MemoryCache);

            foreach (var relation in movieRelations)
            {
                if (relation.CategoryTo == MovieGenre.ENTITY_CATEGORY_ID)
                {
                    movie.AddGenre(await movieGenreRepository.GetById(relation.EntityTo));
                }
            }
        }
        public async Task GetListableItems(MediaList mediaList)
        {
            var relationRepository = new RelationRepository(Configuration, MemoryCache);

            var relList = await relationRepository.GetRelationsByParent(
                mediaList.GetEntityCategoryId(), mediaList.GetId());

            //TODO FIX!!!!
            var movieRepository  = new MovieRepository(Configuration, MemoryCache);
            var tvShowRepository = new TVShowRepository(Configuration, MemoryCache);

            foreach (var relation in relList)
            {
                if (relation.CategoryTo == Movie.ENTITY_CATEGORY_ID)
                {
                    mediaList.AddListableItem(await movieRepository.GetById(relation.EntityTo));
                }
                else if (relation.CategoryTo == TVShow.ENTITY_CATEGORY_ID)
                {
                    mediaList.AddListableItem(await tvShowRepository.GetById(relation.EntityTo));
                }
            }
        }