Example #1
0
        public Movie(string title, int year, Person director, params Country[] countries)
        {
            Check.Require(!string.IsNullOrWhiteSpace(title), "Title is required");
            Check.Require(year > 1850, "No film was recorded prior to 1850");
            Check.Require(director != null, "Someone had to direct the film");
            Check.Require(countries != null && countries.Length > 0, "Al least one country is required");

            Title = title;
            Year = year;
            Director = director;
            Countries = countries.ToList();
        }
        public void LoadData()
        {
            var usa = new Country("USA");
            var spain = new Country("EspaƱa");
            var france = new Country("Francia");

            dbContext.Countries.Add(usa);
            dbContext.Countries.Add(spain);
            dbContext.Countries.Add(france);

            var juanma = new Person("Juanma Bajo Ulloa");
            var james = new Person("James Cameron");

            dbContext.People.Add(juanma);
            dbContext.People.Add(james);

            var airbag = new Movie("Airbag", 1997, juanma, spain);
            var terminator = new Movie("Terminator", 1984, james, usa);

            dbContext.Movies.Add(airbag);
            dbContext.Movies.Add(terminator);

            dbContext.SaveChanges();
        }