Ejemplo n.º 1
0
        public void Add(ActorViewModel actorVm)
        {
            var moviesIds = actorVm.FilmographyIds;
            var actor     = new Actor();
            var movies    = new List <Movie>();

            actor.Update(actorVm);

            foreach (var movieId in moviesIds)
            {
                var movie = _repository.SearchForMovies(x => x.MovieId == movieId).First();
                movies.Add(movie);
            }

            if (movies.Any())
            {
                movies.ForEach(x => _repository.Add(new ActorMovie()
                {
                    Movie = x, Actor = actor
                }));
            }
            else
            {
                _repository.AddActor(actor);
            }
        }
Ejemplo n.º 2
0
        public void Add(MovieViewModel movieVm)
        {
            var actorsIds = movieVm.StarringActorsIds;
            var movie     = new Movie();
            var actors    = new List <Actor>();

            movie.Update(movieVm);

            foreach (var actorId in actorsIds)
            {
                var actor = _repository.SearchForActors(x => x.ActorId == actorId).First();
                actors.Add(actor);
            }

            actors.ForEach(x => _repository.Add(new ActorMovie()
            {
                Movie = movie, Actor = x
            }));
        }