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 override async Task <Movie> GetById(long id) { var isExist = MemoryCache.TryGetValue("CACHEMOVIE" + id, out Movie movie); if (!isExist) { movie = await GetSingleByDesiredParameter(ID_FIELD_NAME, id); MemoryCache.Set("CACHEMOVIE" + id, movie); TrakkerCache.SaveCacheEntry("CACHEMOVIE" + id); } return(movie); }