Beispiel #1
0
        public void AddActorListToDb(List <int> actorIds, int movieID)
        {
            foreach (var id in actorIds)
            {
                var actorToMovie = new ActorToMovie();

                actorToMovie.ActorId = id;
                actorToMovie.MovieID = movieID;

                _db.Actor_Movies.Add(actorToMovie);
                _db.SaveChanges();
            }
        }
        public void Adding()
        {
            // Adding Test Data for Checking 'list-movies' scenario
            var          _movieName1 = "Ford vs Ferrari";
            var          _year1      = "2019";
            var          _plot1      = "American Car Movie";
            List <Actor> _actors1    = new List <Actor>();

            DateTime _dob  = new DateTime();
            string   _date = "01/01/1980";
            var      date  = DateTime.MinValue;

            if (DateTime.TryParse(_date, out date))
            {
                //Sucess...
                _dob = date;
            }

            var _actor1 = new Actor()
            {
                Name = "Matt Damon",
                DOB  = _dob
            };
            var _actor2 = new Actor()
            {
                Name = "Christian Bale",
                DOB  = _dob
            };

            _actors1.Add(_actor1);
            _actors1.Add(_actor2);

            var _producer1 = new Producer()
            {
                Name = "James Mangold",
                DOB  = _dob
            };

            _imdbservice.AddMovie(_movieName1, _year1, _plot1, _actors1, _producer1);

            var          _movieName2 = "Avengers";
            var          _year2      = "2019";
            var          _plot2      = "American Sci-Fi Movie";
            List <Actor> _actors2    = new List <Actor>();
            var          _actor3     = new Actor()
            {
                Name = "RDJ",
                DOB  = _dob
            };
            var _actor4 = new Actor()
            {
                Name = "Chris Evans",
                DOB  = _dob
            };

            _actors2.Add(_actor1);
            _actors2.Add(_actor2);

            var _producer2 = new Producer()
            {
                Name = "Kevin Feigi",
                DOB  = _dob
            };

            _imdbservice.AddMovie(_movieName2, _year2, _plot2, _actors2, _producer2);

            ActorToMovie _actortomovie1 = new ActorToMovie()
            {
                Actor = _actor1.Name,
                DOB   = _actor1.DOB,
                Movie = _movieName1
            };

            ActorToMovie _actortomovie2 = new ActorToMovie()
            {
                Actor = _actor2.Name,
                DOB   = _actor2.DOB,
                Movie = _movieName1
            };
            ActorToMovie _actortomovie3 = new ActorToMovie()
            {
                Actor = _actor3.Name,
                DOB   = _actor3.DOB,
                Movie = _movieName2
            };
            ActorToMovie _actortomovie4 = new ActorToMovie()
            {
                Actor = _actor4.Name,
                DOB   = _actor4.DOB,
                Movie = _movieName2
            };

            ProducerToMovie _producertomovie1 = new ProducerToMovie()
            {
                Producer = _producer1.Name,
                DOB      = _producer1.DOB,
                Movie    = _movieName1
            };

            ProducerToMovie _producertomovie2 = new ProducerToMovie()
            {
                Producer = _producer2.Name,
                DOB      = _producer2.DOB,
                Movie    = _movieName2
            };

            actorToMovie = new List <ActorToMovie> {
                _actortomovie1, _actortomovie2, _actortomovie3, _actortomovie4
            };
            producerToMovie = new List <ProducerToMovie> {
                _producertomovie1, _producertomovie2
            };
        }