Ejemplo n.º 1
0
        /// <summary>
        /// add director to new movie
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnAddDirector_Click(object sender, RoutedEventArgs e)
        {
            if (lbDirectors.SelectedItem == null)
            {
                MessageBox.Show("Must select a director first", "Error",
                                MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }
            MoviePerson      selected = lbDirectors.SelectedItem as MoviePerson;
            MessageBoxResult res      = MessageBox.Show($"Add {selected.FirstName} {selected.LastName} as the movie director?", "Confirm pick",
                                                        MessageBoxButton.YesNo, MessageBoxImage.Question);

            if (res == MessageBoxResult.No)
            {
                return;
            }
            if (!string.IsNullOrEmpty(tbDirector.Text))
            {
                res = MessageBox.Show($"Replace {tbDirector.Text} with {selected.FirstName} {selected.LastName} as the movie director?", "Confirm pick",
                                      MessageBoxButton.YesNo, MessageBoxImage.Question);
                if (res == MessageBoxResult.No)
                {
                    return;
                }
            }
            tbDirector.Text = selected.ToString();
            director        = selected;
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> AddPerson(string personId)
        {
            var split    = personId.Split(",");
            var idPerson = int.Parse(split[0]);
            var idMovie  = int.Parse(split[1]);
            var movie    = await _context.Movies.FirstOrDefaultAsync(m => m.Id == idMovie);

            var person = await _context.Persons.FirstOrDefaultAsync(m => m.Id == idPerson);

            var moviePerson = new MoviePerson()
            {
                PersonId = idPerson, MovieId = idMovie,
                Person   = person, Movie = movie
            };
            var mp = _context.MoviePersons.FirstOrDefault(x =>
                                                          x.PersonId == idPerson && x.MovieId == idMovie
                                                          );

            if (mp == null)
            {
                movie.MoviePersons.Add(moviePerson);
                _context.Add(moviePerson);
                await _context.SaveChangesAsync();
            }

            return(View("Details", movie));
            //return RedirectToAction(nameof(Index));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// create new person from user input
        /// </summary>
        /// <returns></returns>
        private bool generatePerson()
        {
            try
            {
                if (!checkAllBoxesFilled(addMoviePersonMainGrid))
                {
                    throw new Exception("All fields must be filled!");
                }
                myGender    mg   = checkMaleOrFemale();
                bool        dir  = cbDirector.IsChecked == true;
                bool        act  = cbActor.IsChecked == true;
                MoviePerson temp = new MoviePerson(tbFirstName.Text, tbLastName.Text, mg, tbBirthDate.Text, dir, act);
                if (directors.Contains(temp) || actors.Contains(temp))
                {
                    throw new Exception($"{temp.FirstName} {temp.LastName} was added before");
                }
                if (dir == true)
                {
                    directors.Add(temp);
                }
                if (act == true)
                {
                    actors.Add(temp);
                }

                return(true);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                return(false);
            }
        }
        public void InstanceOK()
        {
            //create an instance of the calss we want to create
            MoviePerson AMoviePerson = new MoviePerson();

            //test to see that it exists
            Assert.IsNotNull(AMoviePerson);
        }
Ejemplo n.º 5
0
        private async Task AddActorsToMovie(MovieDTO movieDTO, Movie movie)
        {
            foreach (int actorId in movieDTO.MovieActorsId)
            {
                Person actor = await _context.People.FindAsync(actorId);

                MoviePerson moviePerson = new MoviePerson(movie, actor);
                movie.Add(moviePerson);
            }
        }
        public void personIDPropertyOK()
        {
            //create an instance of the class we want to create
            MoviePerson AMoviePerson = new MoviePerson();
            //create some test data to assign to the property
            int TestData = 1;

            AMoviePerson.personID = TestData;
            //test to see that the two values are the same
            Assert.AreEqual(AMoviePerson.personID, TestData);
        }
Ejemplo n.º 7
0
        public ActionResult AddPeopleToMovie()
        {
            int id = Convert.ToInt32(Request.Params["MovieID"]);


            //selecting people id's from database
            List <int> ListOfPeople = db.People.Select(p => p.personID).ToList();

            List <int>    ListOfPeopleSendedFromWeb = new List <int>();
            List <Person> EmptyPeople = new List <Person>();

            foreach (int personid in ListOfPeople)
            {
                if (Request.Params[personid.ToString()] != null)
                {
                    int    x   = Convert.ToInt32(Request.Params[personid.ToString()]);
                    Person prs = new Person();
                    EmptyPeople.Add(db.People.Where(p => p.personID == x).Single());
                    //adding to movie person
                    MoviePerson mope = new MoviePerson();
                    mope.MovieID  = id;
                    mope.personID = x;
                    db.MoviePerson.Add(mope);


                    //  ListOfPeopleSendedFromWeb.Add(personid);
                }
                db.SaveChanges();
            }


            Movie movie = db.Movies.Find(id); //

            int numerFilmu = movie.MovieID;   //

            ViewBag.movie = movie.MovieName;
            List <MoviePerson> mp = db.MoviePerson.Where(i => i.MovieID == numerFilmu).ToList();

            /// List<Person> lstPpl = db.People.ToList();
            movie.People = EmptyPeople;

            if (movie == null)
            {
                return(HttpNotFound());
            }
            //return View(movie);
            return(RedirectToAction("Details/" + id));
        }
Ejemplo n.º 8
0
        private void buttonAdd_Click(object sender, RoutedEventArgs e)
        {
            FirstName = tbFName.Text.ToString();
            LastName  = tbLName.Text.ToString();
            string      genderValue = gender.Text.ToString();
            string      date        = datePicker.Text.ToString();
            Gender      g           = genderValue.Equals("Female") ? Gender.Female : Gender.Male;
            MoviePerson person      = new MoviePerson(FirstName, LastName, new DateTime(2020, 1, 1), g);

            if (!actorsList.Contains(person))
            {
                actorsList.Add(person);
            }
            else
            {
                MessageBox.Show("The actor already exist, please try again!");
            }
        }
 /// <summary>
 /// Maps Messaging.Views.MoviePerson into Api.ModelsMoviePersonViewModel
 /// </summary>
 /// <param name="view">Messaging.Views.MoviePerson</param>
 /// <returns>MoviePersonViewModel</returns>
 public static MoviePersonViewModel MapToViewModel(this MoviePerson view)
 {
     if (view == null)
     {
         return(null);
     }
     return(new MoviePersonViewModel()
     {
         Id = view.Id,
         Firstname = view.FirstName,
         Lastname = view.LastName,
         FullName = view.FullName,
         Birthplace = view.BirthPlace,
         Biography = view.Biography,
         Photourl = view.PhotoUrl,
         Popularity = view.Popularity,
         Birthday = view.Birthday,
         Datecreated = view.DateCreated,
         IMDBUrl = view.IMDBUrl,
         UserLastModified = view.UserLastModified.MapToViewModel(),
         UserCreated = view.UserCreated.MapToViewModel()
     });
 }
Ejemplo n.º 10
0
        /// <summary>
        /// add actor to new movie
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnAddActor_Click(object sender, RoutedEventArgs e)
        {
            if (lbActors.SelectedItem == null)
            {
                MessageBox.Show("Must select an actor first", "Error",
                                MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }
            MoviePerson      selected = lbActors.SelectedItem as MoviePerson;
            MessageBoxResult res      = MessageBox.Show($"Add {selected.FirstName} {selected.LastName} as the movie actor?", "Confirm pick",
                                                        MessageBoxButton.YesNo, MessageBoxImage.Question);

            if (res == MessageBoxResult.No)
            {
                return;
            }
            if (actors.Count != 0 && actors.Contains(selected.ToString()) == true)
            {
                MessageBox.Show($"{selected.FirstName} {selected.LastName} was already picked", "Error",
                                MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }
            actors.Add($"{selected.FirstName} {selected.LastName}");
        }
Ejemplo n.º 11
0
        public void FillDbWithData()
        {
            Country country1 = new Country {
                Name = "Poland"
            };
            Country country2 = new Country {
                Name = "Vietnam"
            };

            Person director1 = new Person
            {
                FirstName   = "Joe",
                LastName    = "Doe",
                Type        = TypeOfPeople.DIRECTOR,
                DateOfBirth = DateTime.Now,
                DateOfDeath = DateTime.Now,
                Sex         = TypeOfSex.MALE,
                Country     = country1
            };

            Person actor1 = new Person
            {
                FirstName   = "Stefa",
                LastName    = "Rychu",
                Type        = TypeOfPeople.ACTOR,
                DateOfBirth = DateTime.Now,
                DateOfDeath = DateTime.Now,
                Sex         = TypeOfSex.FEMALE,
                Country     = country2
            };

            Person actor2 = new Person
            {
                FirstName   = "Rychu",
                LastName    = "Peja",
                Type        = TypeOfPeople.ACTOR,
                DateOfBirth = DateTime.Now,
                DateOfDeath = DateTime.Now,
                Sex         = TypeOfSex.MALE,
                Country     = country1
            };

            Movie movie1 = new Movie
            {
                Title    = "Snoop doog",
                Director = director1,
                Genre    = TypesOfGenre.COMEDY,
                Length   = 127,
                Year     = DateTime.Now,
                Country  = country2
            };

            Producer producer1 = new Producer
            {
                CompanyName           = "Test Company",
                YearEstablished       = DateTime.Now,
                EstimatedCompanyValue = 40000000,
                Country = country1,
            };

            MoviePerson   moviePerson1   = new MoviePerson(movie1, actor1);
            MoviePerson   moviePerson2   = new MoviePerson(movie1, actor2);
            MovieProducer movieProducer1 = new MovieProducer(movie1, producer1);

            movie1.Add(moviePerson1);
            movie1.Add(moviePerson2);
            movie1.Add(movieProducer1);

            _context.Movies.Add(movie1);
            _context.SaveChanges();
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Handle load data from file at application initialization process
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// <summary>
        /// Get data from XML file
        /// </summary>
        void readDataFromXml()
        {
            XmlTextReader reader = new XmlTextReader(fileData);

            reader.WhitespaceHandling = WhitespaceHandling.None;
            while (reader.Name != "DATA")
            {
                reader.Read();
            }

            //Read movie directors
            while (reader.Name != "MovieDirectors")
            {
                reader.Read();
            }
            reader.Read();
            while (reader.Name == "MovieDirector")
            {
                MoviePerson a;

                reader.ReadStartElement("MovieDirector");
                string fn  = reader.ReadElementString("FN");
                string ln  = reader.ReadElementString("LN");
                string gen = reader.ReadElementString("GEN");
                string bd  = reader.ReadElementString("BD");
                MoviePerson.myGender g;
                if (gen.Equals("male"))
                {
                    g = MoviePerson.myGender.male;
                }
                else
                {
                    g = MoviePerson.myGender.female;
                }
                a = new MoviePerson(fn, ln, g, bd, true, false);
                movieDirectors.Add(a);
                reader.ReadEndElement();
            }

            //Read movie actors
            while (reader.Name != "MovieActors")
            {
                reader.Read();
            }
            reader.Read();
            while (reader.Name == "MovieActor")
            {
                MoviePerson a;

                reader.ReadStartElement("MovieActor");
                string fn  = reader.ReadElementString("FN");
                string ln  = reader.ReadElementString("LN");
                string gen = reader.ReadElementString("GEN");
                MoviePerson.myGender g;
                if (gen.Equals("male"))
                {
                    g = MoviePerson.myGender.male;
                }
                else
                {
                    g = MoviePerson.myGender.female;
                }
                string bd = reader.ReadElementString("BD");
                a = new MoviePerson(fn, ln, g, bd, false, true);
                movieActors.Add(a);
                reader.ReadEndElement();
            }

            //Read movies
            while (reader.Name != "Movies")
            {
                reader.Read();
            }
            reader.Read();
            while (reader.Name == "Movie")
            {
                reader.ReadStartElement("Movie");

                string        title        = reader.ReadElementString("Title");
                string        dir          = reader.ReadElementString("Dir");
                MoviePerson   realDirector = findMoviePersonByName(dir);
                int           year         = int.Parse(reader.ReadElementString("Year"));
                int           RT           = int.Parse(reader.ReadElementString("RTS"));
                decimal       IS           = decimal.Parse(reader.ReadElementString("IS"));
                List <string> actors       = new List <string>();
                while (reader.Name == "Actor")
                {
                    actors.Add(reader.ReadElementString("Actor"));
                }

                Movie m = new Movie(title, realDirector, year, RT, IS, actors);
                movies.Add(new MyKeyPair(title, year), m);
                reader.ReadEndElement();
            }

            reader.Close();
        }
Ejemplo n.º 13
0
        private void uxSearchProduction_Click(object sender, EventArgs e)
        {
            personrepo = new SqlMoviePersonsRepository("Data Source=mssql.cs.ksu.edu;" +
                                                       "Initial Catalog=phyo;" +
                                                       "User id=UserId;" +
                                                       "Password=Password;");
            person = new SqlPersonRepository("Data Source=mssql.cs.ksu.edu;" +
                                             "Initial Catalog=phyo;" +
                                             "User id=UserId;" +
                                             "Password=Password;");

            movieAwardsWon = new SqlMovieAwardsWonRepository("Data Source=mssql.cs.ksu.edu;" +
                                                             "Initial Catalog=phyo;" +
                                                             "User id=UserId;" +
                                                             "Password=Password;");
            movieCategory = new SqlMovieRepository("Data Source=mssql.cs.ksu.edu;" +
                                                   "Initial Catalog=phyo;" +
                                                   "User id=UserId;" +
                                                   "Password=Password;");
            Inrepo = new SqlIndividualAwardsWonRepository("Data Source=mssql.cs.ksu.edu;" +
                                                          "Initial Catalog=phyo;" +
                                                          "User id=UserId;" +
                                                          "Password=Password;");

            List <Movie> won = new List <Movie>();

            if (this.listBox2.SelectedItem.Equals("Best Picture"))
            {
                foreach (MovieAwardsWon i in movieAwardsWon.RetrieveMovieAwardsWon())
                {
                    if (i.Category.Equals("Best Picture"))
                    {
                        Movie a = movieCategory.FetchMovie(i.MovieId);
                        won.Add(a);
                    }
                }
                dataGridView1.DataSource = won;
            }


            List <Person> won1 = new List <Person>();

            if (this.listBox2.SelectedItem.Equals("Director"))
            {
                foreach (IndividualAwardsWon i in Inrepo.RetrieveIndividualAwardsWon())
                {
                    MoviePerson a = personrepo.FetchMoviePerson(i.MoviePersonId);
                    if (a.Role.Equals("Director"))
                    {
                        Person b = person.FetchPerson(a.PersonId);
                        won1.Add(b);
                    }
                }
                dataGridView1.DataSource = won1;
            }
            if (this.listBox2.SelectedItem.Equals("Adapted Screenplay"))
            {
                foreach (MovieAwardsWon i in movieAwardsWon.RetrieveMovieAwardsWon())
                {
                    if (i.Category.Equals("Adapted Screenplay"))
                    {
                        Movie a = movieCategory.FetchMovie(i.MovieId);
                        won.Add(a);
                    }
                }
                dataGridView1.DataSource = won;
            }
        }
Ejemplo n.º 14
0
 public void Add(MoviePerson moviePerson)
 {
     MoviePerson.Add(moviePerson);
 }
Ejemplo n.º 15
0
        public IActionResult Add(MovieVM model, int[] genres, int[] directorarray, int[] scenaristarray, int[] stararray)
        {
            string imagepath = "";

            if (model.movieposter != null)
            {
                var guid = Guid.NewGuid().ToString();
                var path = Path.Combine(
                    Directory.GetCurrentDirectory(),
                    "wwwroot/adminsite/movieposter", guid + ".jpg");
                using (var stream = new FileStream(path, FileMode.Create))
                {
                    model.movieposter.CopyTo(stream);
                }
                imagepath = guid + ".jpg";
            }

            List <string> paths = new List <string>();

            string imgpaths = "";

            if (model.movieImages != null)
            {
                foreach (var item in model.movieImages)
                {
                    var guid = Guid.NewGuid().ToString();

                    var path = Path.Combine(
                        Directory.GetCurrentDirectory(),
                        "wwwroot/adminsite/movieimages", guid + ".jpg");
                    using (var stream = new FileStream(path, FileMode.Create))
                    {
                        item.CopyTo(stream);
                    }

                    imgpaths = guid + ".jpg";
                    paths.Add(imgpaths);
                }
            }

            model.imagepaths = paths;


            if (ModelState.IsValid)
            {
                Movie movie = new Movie();
                movie.Name        = model.name;
                movie.Duration    = model.duration;
                movie.ReleaseDate = model.releasedate;
                movie.PosterURL   = imagepath;
                movie.Description = model.description;

                _context.Movies.Add(movie);
                _context.SaveChanges();

                int MovieID = movie.ID;

                foreach (var item in genres)
                {
                    MovieGenre movieGenre = new MovieGenre();
                    movieGenre.MovieID = MovieID;
                    movieGenre.GenreID = item;

                    _context.MovieGenres.Add(movieGenre);
                }
                foreach (var item in directorarray)
                {
                    MoviePerson moviePerson = new MoviePerson();
                    moviePerson.MovieID  = MovieID;
                    moviePerson.PersonID = item;
                    moviePerson.JobID    = 1;

                    _context.MoviePeople.Add(moviePerson);
                }

                foreach (var item in scenaristarray)
                {
                    MoviePerson moviePerson = new MoviePerson();
                    moviePerson.MovieID  = MovieID;
                    moviePerson.PersonID = item;
                    moviePerson.JobID    = 2;
                    _context.MoviePeople.Add(moviePerson);
                }

                foreach (var item in stararray)
                {
                    MoviePerson moviePerson = new MoviePerson();
                    moviePerson.MovieID  = MovieID;
                    moviePerson.PersonID = item;
                    moviePerson.JobID    = 3;
                    _context.MoviePeople.Add(moviePerson);
                }

                foreach (var item in model.imagepaths)
                {
                    MovieImages image = new MovieImages();
                    image.ImagePath = item;
                    image.MovieID   = MovieID;

                    _context.MovieImages.Add(image);
                }
                _context.SaveChanges();

                //return RedirectToAction("Index", "Movie");
                return(Redirect("/Admin/Movie/Index"));
            }
            else
            {
                return(View(getGenresJob()));
            }
        }
Ejemplo n.º 16
0
        public void FillDbWithData()
        {
            Country country1 = new Country {
                Name = "Poland"
            };
            Country country2 = new Country {
                Name = "Vietnam"
            };
            Country country3 = new Country {
                Name = "France"
            };

            Person director1 = new Person
            {
                FirstName   = "Joe",
                LastName    = "Doe",
                Type        = TypeOfPeople.DIRECTOR,
                DateOfBirth = DateTime.Now,
                DateOfDeath = DateTime.Now,
                Sex         = TypeOfSex.MALE,
                Country     = country1
            };

            Person director2 = new Person
            {
                FirstName   = "Coco",
                LastName    = "Jambo",
                Type        = TypeOfPeople.DIRECTOR,
                DateOfBirth = DateTime.Now,
                DateOfDeath = DateTime.Now,
                Sex         = TypeOfSex.MALE,
                Country     = country3
            };

            Person actor1 = new Person
            {
                FirstName   = "Stefa",
                LastName    = "Rychu",
                Type        = TypeOfPeople.ACTOR,
                DateOfBirth = DateTime.Now,
                DateOfDeath = DateTime.Now,
                Sex         = TypeOfSex.FEMALE,
                Country     = country2
            };

            Person actor2 = new Person
            {
                FirstName   = "Rychu",
                LastName    = "Peja",
                Type        = TypeOfPeople.ACTOR,
                DateOfBirth = DateTime.Now,
                DateOfDeath = DateTime.Now,
                Sex         = TypeOfSex.MALE,
                Country     = country1
            };

            Person actor3 = new Person
            {
                FirstName   = "Seba",
                LastName    = "Przykuc",
                Type        = TypeOfPeople.ACTOR,
                DateOfBirth = DateTime.Now,
                DateOfDeath = DateTime.Now,
                Sex         = TypeOfSex.MALE,
                Country     = country3
            };

            Person actor4 = new Person
            {
                FirstName   = "Karyna",
                LastName    = "Bombelek",
                Type        = TypeOfPeople.ACTOR,
                DateOfBirth = DateTime.Now,
                DateOfDeath = DateTime.Now,
                Sex         = TypeOfSex.MALE,
                Country     = country3
            };

            Movie movie1 = new Movie
            {
                Title    = "Snoop doog",
                Director = director1,
                Genre    = TypesOfGenre.COMEDY,
                Length   = 127,
                Year     = DateTime.Now,
                Country  = country2
            };

            Movie movie2 = new Movie
            {
                Title    = "Kac Krakow",
                Director = director2,
                Genre    = TypesOfGenre.DRAMA,
                Length   = 101,
                Year     = DateTime.Now,
                Country  = country1
            };

            Movie movie3 = new Movie
            {
                Title    = "Zycie ostre jak maczeta",
                Director = director2,
                Genre    = TypesOfGenre.FANTASY,
                Length   = 101,
                Year     = DateTime.Now,
                Country  = country1
            };

            Producer producer1 = new Producer
            {
                CompanyName           = "Test Company",
                YearEstablished       = DateTime.Now,
                EstimatedCompanyValue = 40000000,
                Country = country1,
            };

            Producer producer2 = new Producer
            {
                CompanyName           = "Januszex POL",
                YearEstablished       = DateTime.Now,
                EstimatedCompanyValue = 999999999999,
                Country = country2,
            };

            MoviePerson   movie1Person1   = new MoviePerson(movie1, actor1);
            MoviePerson   movie1Person2   = new MoviePerson(movie1, actor2);
            MoviePerson   movie2Person1   = new MoviePerson(movie2, actor2);
            MoviePerson   movie2Person2   = new MoviePerson(movie2, actor4);
            MoviePerson   movie3Person1   = new MoviePerson(movie3, actor3);
            MoviePerson   movie3Person2   = new MoviePerson(movie3, actor4);
            MovieProducer movie1Producer1 = new MovieProducer(movie1, producer1);
            MovieProducer movie2Producer1 = new MovieProducer(movie2, producer2);
            MovieProducer movie2Producer2 = new MovieProducer(movie2, producer1);
            MovieProducer movie3Producer1 = new MovieProducer(movie3, producer2);

            movie1.Add(movie1Person1);
            movie1.Add(movie1Person2);
            movie1.Add(movie1Producer1);

            movie2.Add(movie2Person1);
            movie2.Add(movie2Person2);
            movie2.Add(movie2Producer1);
            movie2.Add(movie2Producer2);


            movie3.Add(movie3Person1);
            movie3.Add(movie3Person2);
            movie3.Add(movie3Producer1);

            _context.Movies.Add(movie1);
            _context.Movies.Add(movie2);
            _context.Movies.Add(movie3);
            _context.SaveChanges();
        }