Пример #1
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);
            }
        }
Пример #2
0
 public MoviePerson(string fn, string ln, myGender gen, string bd, bool dir, bool act)
 {
     FirstName  = fn;
     LastName   = ln;
     Gender     = gen;
     BirthDate  = bd;
     IsDirector = dir;
     IsActor    = act;
 }