Exemplo n.º 1
0
        public string Execute(IList <string> parameters)
        {
            var movieName     = parameters[0];
            var rating        = float.Parse(parameters[1]);
            var publishDate   = DateTime.Parse(parameters[2], new CultureInfo("en-CA"));
            var length        = int.Parse(parameters[3]);
            var directorToAdd = utils.FindCurrentArtist(parameters[4], Profession.Director);
            var countryToAdd  = utils.FindCurrentCountry(parameters[5]);
            var genreToAdd    = utils.FindCurrentGenre(parameters[6]);

            var movie = new Movie
            {
                Name        = movieName,
                Rating      = rating,
                PublishDate = publishDate,
                Length      = length,
                Director    = directorToAdd,
                Coutry      = countryToAdd,
                Genre       = genreToAdd
            };

            while (true)
            {
                this.writer.WriteLine("Enter actor (or type end to terminate) : ");
                var input = this.reader.Read();

                if (input.ToLower() == "end")
                {
                    break;
                }
                else if (string.IsNullOrEmpty(input))
                {
                    this.writer.WriteLine("Enter an actor or terminate process");
                }

                var actorToAdd = utils.FindCurrentArtist(input, Profession.Actor);

                movie.Actors.Add(actorToAdd);
            }

            dbContext.Movies.AddOrUpdate(m => m.Name, movie);

            dbContext.SaveChanges();

            return($"{movie.Name} has been successfully created!");
        }
        public string Execute(IList <string> parameters)
        {
            var artistFirstName = parameters[0];
            var artistLastName  = parameters[1];
            var dateOfBirth     = DateTime.Parse(parameters[2], new CultureInfo("en-CA"));
            var profession      = (Profession)Enum.Parse(typeof(Profession), parameters[3]);
            var countryToAdd    = utils.FindCurrentCountry(parameters[4]);

            var artist = new Artist
            {
                FirstName   = artistFirstName,
                LastName    = artistLastName,
                DateOfBirth = dateOfBirth,
                Profession  = profession,
                Country     = countryToAdd,
            };

            dbContext.Artists.Add(artist);
            dbContext.SaveChanges();

            return($"{artist.FirstName} {artist.LastName} has been successfully added!");
        }