public ActionResult List() { Artist artist = new Artist { Name = "Travis Scott" }; var albums = new List <Album>(); albums.Add(new Album { AlbumId = 0, Title = "Rodeo" }); albums.Add(new Album { AlbumId = 1, Title = "Birds In The Trap Sing McKnight" }); albums.Add(new Album { AlbumId = 2, Title = "Astroworld" }); albums.Add(new Album { AlbumId = 3, Title = "JACKBOYS" }); var viewModel = new ArtistAlbums { Artist = artist, Albums = albums }; return(View(viewModel)); }
private void ConfirmAndWasteArtist(bool isWaste, IList <Album> albums) { ConfirmDialog confirm = new ConfirmDialog() { HeaderText = isWaste == true ? "Confirm waste mark" : "Confirm waste mark removal", MessageText = isWaste == true?String.Format("Do you really want to mark artist {0} as wasted?", CurrentArtist.Name) : String.Format("Do you really want to unmark artist {0} as wasted?", CurrentArtist.Name), CheckBoxText = isWaste ? String.Format("Also waste all albums of {0}", CurrentArtist.Name) : String.Empty }; if (confirm.ShowDialog() == true) { bool wasteChildAlbums = confirm.CheckBoxChecked; CurrentArtist.IsWaste = isWaste; IsBusy = true; Task <bool> saveArtistTask = Task.Factory.StartNew <bool>(() => { return(dataService.SaveArtistWasted(CurrentArtist, wasteChildAlbums)); }, TaskScheduler.Default); Task finishedTask = saveArtistTask.ContinueWith((t) => { IsBusy = false; if (t.Result) { LoadArtists(); if (!IsWasteVisible) { // selected artists becomes invisible, so hide it's albums also ArtistAlbums.Clear(); } } else { Notify("Can't update artist. See log for details", NotificationType.Error); } }, TaskScheduler.FromCurrentSynchronizationContext()); } }