/// <summary> /// Adds tags to the movie specified in the argument based on the /// provided list of words and their definitions. /// </summary> /// <param name="words"></param> private async Task AutoTagMovie(List <string> words, string movieId) { foreach (var word in words) { Word dbWord = _repo.GetWord(word); if (dbWord == null) { var wordObject = await ApiHelper.ApiProcessor.LoadDefinitionAsync(word); bool wordIsTag = ProcessWordObject(word, wordObject); if (wordIsTag) { var movieTagUser = new MovieTagUser(); movieTagUser.ImdbId = movieId; movieTagUser.UserId = "~AutoGenerated"; movieTagUser.TagName = wordObject.Word; movieTagUser.IsUpvote = true; if (!_repo.MovieTagUserExists(movieTagUser)) { _repo.AddMovieTagUser(movieTagUser); } } } else { if (dbWord.IsTag) { var movieTagUser = new MovieTagUser(); movieTagUser.ImdbId = movieId; movieTagUser.UserId = "~AutoGenerated"; movieTagUser.TagName = dbWord.BaseWord; movieTagUser.IsUpvote = true; if (!_repo.MovieTagUserExists(movieTagUser)) { _repo.AddMovieTagUser(movieTagUser); } } } } }