public async Task <bool> DeleteAlbum(object sender) { try { AlbumsVMManager.DeleteAlbum(this); _photos.ToList().ForEach(p => UnsubscribeFromPhotoEvents(p)); IsDeleted = true; AlbumDeleted?.Invoke(this, EventArgs.Empty); return(true); } catch (Exception ex) { await Utils.ShowContentDialog("Delete Album", ex.Message); return(false); } }
public async void EditAlbum() { AlbumContentDialog albumDialog = new AlbumContentDialog(this); ShowAlbumDialog: ContentDialogResult result = await albumDialog.ShowAsync(); if (result == ContentDialogResult.Secondary) { // Revert changes AlbumsVMManager.SetViewModelFromModel(this); return; } if (result == ContentDialogResult.Primary) { try { AlbumsVMManager.UpdateAlbum(this); } catch (DuplicateObjectException) { await Utils.ShowContentDialog( "Edit Album", "Name already exists. Please chose a different one."); goto ShowAlbumDialog; } catch (RequiredConstraintViolationException) { await Utils.ShowContentDialog( "Edit Album", "You must set another album as 'Main', before unsetting 'Main' from this one."); goto ShowAlbumDialog; } catch (Exception ex) { await Utils.ShowContentDialog("Edit Album", ex.Message); goto ShowAlbumDialog; } AlbumEdited?.Invoke(this, EventArgs.Empty); } }
private async void AddAlbum() { AlbumContentDialog albumDialog = new AlbumContentDialog(); ShowNewAlbumDialog: ContentDialogResult result = await albumDialog.ShowAsync(); if (result == ContentDialogResult.Primary) { var newAlbum = albumDialog.AlbumViewModel; if (newAlbum.HasErrors) { return; } try { AlbumsVMManager.AddAlbum(newAlbum); } catch (DuplicateObjectException) { await Utils.ShowContentDialog( "Add Album", "Name already exists. Please choose a different one."); goto ShowNewAlbumDialog; } catch (Exception ex) { await Utils.ShowContentDialog("Add Album", ex.Message); goto ShowNewAlbumDialog; } _albums.Add(newAlbum); NavigateTo(newAlbum); } }