private async Task AddMoviesToRepositoryAsync(List <MovieDO> movies)
 {
     foreach (var movie in movies)
     {
         await _movieRepository.AddMovieAsync(movie);
     }
 }
Exemplo n.º 2
0
        public async Task <int> Handle(CreateMovieCommand request, CancellationToken cancellationToken)
        {
            var movie = new Movie(request.Title, request.Overview, request.VoteCount, request.VoteAvarage, request.Popularity);

            foreach (var genre in request.Genres)
            {
                movie.Genres.Add(new MovieGenre(movie.Id, genre.Id));
            }

            foreach (var actor in request.Actors)
            {
                movie.Actors.Add(new MovieActor(movie.Id, actor.Id));
            }

            foreach (var productionCompany in request.ProductionCompanies)
            {
                movie.ProductionComapanies.Add(new MovieProductionCompany(movie.Id, productionCompany.Id));
            }

            foreach (var directory in request.Directors)
            {
                movie.Directors.Add(new MovieDirector(movie.Id, directory.Id));
            }

            await _movie.AddMovieAsync(movie);

            return(movie.Id);
        }
Exemplo n.º 3
0
 public async Task <ActionResult> Create(Movie movie)
 {
     if (ModelState.IsValid)
     {
         await _repository.AddMovieAsync(movie);
     }
     else
     {
         return(new HttpStatusCodeResult((int)HttpStatusCode.BadRequest, "Bad Request"));
     }
     return(RedirectToAction("Index", "Home"));
 }