예제 #1
0
        private void buttonDeleteGenre_Click(object sender, RoutedEventArgs e)
        {
            if (listBoxGenres.SelectedIndex != -1)
            {
                Genre selectedGenre = (Genre)listBoxGenres.SelectedItem;
                var   window        = new DeleteGenreWindow(selectedGenre);
                if (window.ShowDialog().Value)
                {
                    int originalId    = selectedGenre.Id;
                    int replacementId = window.Replacement.Id;

                    Data.ReadGenresData();
                    foreach (Movie movie in Data.Movies)
                    {
                        if (movie.GenreId == originalId)
                        {
                            movie.GenreId = replacementId;
                        }
                    }

                    Data.Genres.RemoveAll(genre => genre.Id == originalId);
                    Data.UpdateGenresData();
                    RefreshListBoxGenres();
                    textBoxSearchGenres.Text = "";
                    Logger.Log($"Удалён жанр \"{selectedGenre.Name}\" с заменой на \"{window.Replacement.Name}\"");
                }
            }
        }
예제 #2
0
 public ControlPage()
 {
     InitializeComponent();
     Data.ReadUsersData();
     Data.ReadGenresData();
     RefreshListBoxUsers();
     RefreshListBoxGenres();
 }
예제 #3
0
        private void buttonAddGenre_Click(object sender, RoutedEventArgs e)
        {
            var window = new AddGenreWindow();

            if (window.ShowDialog().Value)
            {
                Data.ReadGenresData();
                Data.Genres.Add(window.NewGenre);
                Data.UpdateGenresData();
                Data.IsSearched = false;
                UpdateButtonsGenres();
                RefreshListBoxGenres();
                Logger.Log($"Добавлен новый жанр: \"{window.NewGenre.Name}\"");
            }
        }