private void _btnAddMedia_Click(object sender, RoutedEventArgs e) { if (string.IsNullOrEmpty(_vm.Album.AlbumCode)) { MessageBox.Show("Please enter album code."); return; } var dialog = new OpenFileDialog(); dialog.CheckFileExists = true; dialog.Multiselect = true; dialog.Filter = "mp3|*.mp3"; if (dialog.ShowDialog().Value) { try { CmsAssetVM selectedAsset = null; foreach (var filename in dialog.FileNames) { if (_assetService.CheckAssetExists(_vm.Album.AlbumCode, System.IO.Path.GetFileName(filename)) || _vm.Album.Assets.Where(p => !string.IsNullOrEmpty(p.NewFilePath) && p.NewFilePath.Equals(filename, StringComparison.InvariantCultureIgnoreCase)).Any()) { MessageBox.Show(string.Format("Asset {0} already exists in album.", System.IO.Path.GetFileName(filename))); continue; } var cmsAsset = _assetService.GetCmsAssetFromFile(filename); if (cmsAsset != null) { cmsAsset.TrackCode = _vm.Album.Assets.Count + 1; var cmsAssetVM = _vm.Album.AddCmsAsset(cmsAsset); cmsAssetVM.CustomID = _assetService.GetCustomID(_vm.Album.AlbumCode, cmsAssetVM.TrackCode); cmsAssetVM.Label = _vm.Album.Label; cmsAssetVM.YoutubeLabel = _vm.Album.Label; selectedAsset = cmsAssetVM; } } if (selectedAsset != null) { _vm.Asset = selectedAsset; } } catch (Exception ex) { MessageBox.Show(ex.Message); } } }