예제 #1
0
        // Movies
        public void AddMovie(string name, string year, string plot, List <Actor> actors, Producer producer)
        {
            if (string.IsNullOrEmpty(name))
            {
                throw new ArgumentException("Movie name can't be empty!");
            }

            if (Convert.ToInt32(year) < 1000 || Convert.ToInt32(year) > 2021)
            {
                throw new Exception("Invalid Year!");
            }

            if (string.IsNullOrEmpty(plot))
            {
                throw new ArgumentException("Plot can't be empty!");
            }

            if (!actors.Any())
            {
                throw new ArgumentException("Invalid choice of Actor!");
            }


            Movie movie = new Movie()
            {
                Name     = name,
                Year     = year,
                Plot     = plot,
                Actors   = actors,
                Producer = producer
            };

            _movieRepository.AddMovieData(movie);
        }