Пример #1
0
        public override void Execute(object parameter)
        {
            var viewModel = (SongViewModel)parameter;
            var song      = new SongDb();


            var sw = new SongWindow();

            sw.DataContext = song;
            sw.ShowDialog();

            if (sw.DialogResult.HasValue && sw.DialogResult.Value)
            {
                using (var db = new SongDbContext())
                {
                    db.Songs.Add(song);
                    db.SaveChanges();
                }
                viewModel.Songs.Add(SongViewModel.SongConverter(song));
                viewModel.SelectedSong = SongViewModel.SongConverter(song);
            }
        }
Пример #2
0
        public override bool CanExecute(object parameter)
        {
            SongViewModel viewModel = parameter as SongViewModel;

            return(viewModel != null && viewModel.SelectedSong != null);
        }