Пример #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;
        }
Пример #2
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}");
        }