Example #1
0
        public async Task <MovieDTO> GetMovie(string movieId)
        {
            if (_repo.MovieExists(movieId))
            {
                Movie movie = _repo.GetMovieFullInfo(movieId);

                var tagNamesToRemove = new List <string>();
                foreach (var movieTag in movie.MovieTags)
                {
                    var tag = _repo.GetTag(movieTag.TagName);
                    if (tag == null || tag.IsBanned)
                    {
                        tagNamesToRemove.Add(movieTag.TagName);
                    }
                }
                foreach (var tagNameToRemove in tagNamesToRemove)
                {
                    movie.MovieTags.Remove(movie.MovieTags.First(mt => mt.TagName == tagNameToRemove));
                }

                return(Mapper.MovieToMovieDTO(movie));
            }

            ApiHelper.MovieObject movieObject = await ApiHelper.ApiProcessor.LoadMovieAsync(movieId);

            if (movieObject == null || movieObject.imdbID != movieId)
            {
                return(null);
            }
            return(Mapper.MovieObjectToMovieDTO(movieObject));
        }