Exemple #1
0
        /// <summary>
        /// Removes any movies from the list argument that are not tagged
        /// with all of the provided tag names.
        /// </summary>
        /// <param name="movies"></param>
        /// <param name="tagName"></param>
        private List <string> FilterMoviesByTags(string[] tagNames)
        {
            var filterResults = new List <List <string> >();

            foreach (var tagName in tagNames)
            {
                string baseTagName;
                var    word = _repo.GetWord(tagName);
                if (word == null || String.IsNullOrEmpty(word.BaseWord))
                {
                    baseTagName = tagName;
                }
                else
                {
                    baseTagName = word.BaseWord;
                }
                var movieTags    = _repo.GetMovieTagsByName(baseTagName);
                var filterResult = new List <string>();
                foreach (var movieTag in movieTags)
                {
                    filterResult.Add(movieTag.ImdbId);
                }
                filterResults.Add(filterResult);
            }

            var movieIds = GetIntersection(filterResults);

            return(movieIds);
        }