コード例 #1
0
        public async Task <IActionResult> AddMovie()
        {
            Movie movie = new Movie
            {
                Title = "Awesome Movie",
                Year  = "2014",
                Id    = "12345"
            };

            await
            _movieService.AddOrUpdateMovieWithRelationAsync(movie,
                                                            (await _personService.GetPersonByNameAsync("Will Czifro")), RelationTypes.ActedIn);

            var m = await _movieService.GetMovieByTitleAndYearAsync(movie.Title, movie.Year);

            return(Ok(m));
        }
        private static void RelationshipMaker(IMovieService movieService, IPersonService personService, ConcurrentQueue queue)
        {
            while (queue.IncompleteMoviesWaiting() || queue.IncompletePersonsWaiting() || queue.RelationshipsPending())
            {
                if (!queue.RelationshipsPending())
                {
                    continue;
                }

                var relationship = queue.PopRelationship();

                var movie  = movieService.GetMovieByIdAsync(relationship.MovieId).Result;
                var person = personService.GetPersonByNameAsync(relationship.PersonName).Result;

                if (movie == null ||
                    person == null)
                {
                    queue.PushRelationship(relationship);
                    continue;
                }

                movieService.AddOrUpdateMovieWithRelationAsync(movie, person, relationship.RelationType).Wait();
            }
        }
        private static void RelationshipMaker(IMovieService movieService, IPersonService personService, ConcurrentQueue queue)
        {
            while (queue.IncompleteMoviesWaiting() || queue.IncompletePersonsWaiting() || queue.RelationshipsPending())
            {
                if (!queue.RelationshipsPending()) continue;

                var relationship = queue.PopRelationship();

                var movie = movieService.GetMovieByIdAsync(relationship.MovieId).Result;
                var person = personService.GetPersonByNameAsync(relationship.PersonName).Result;

                if (movie == null ||
                    person == null)
                {
                    queue.PushRelationship(relationship);
                    continue;
                }

                movieService.AddOrUpdateMovieWithRelationAsync(movie, person, relationship.RelationType).Wait();
            }
        }