public async void ToggleFavoriteNotation() { if (HasFavoritedNotation) { // unfavoriting var success = await _serviceFavorites.Delete <bool>(_notationId); if (success) { _favoriteToolbarItem.IconImageSource = ImageSource.FromFile("star_empty.png"); HasFavoritedNotation = false; NotationStorageHelper.Remove(_notationId); } } else { // favoriting var request = new Model.Requests.FavoritesInsertRequest { NotationId = _notationId }; var entity = await _serviceFavorites.Insert <Model.Favorites>(request); if (entity != null) { _favoriteToolbarItem.IconImageSource = ImageSource.FromFile("star_filled.png"); HasFavoritedNotation = true; } } }
public async void DownloadNotation() { var notation = NotationStorageHelper.Get(_notationId); if (notation != null) { NotationStorageHelper.Remove(_notationId); _downloadToolbarItem.IconImageSource = ImageSource.FromFile("icon_download.png"); await Application.Current.MainPage.DisplayAlert("Success", "Notation has been deleted from the device.", "OK"); } else { await NotationStorageHelper.Add(_notation); _downloadToolbarItem.IconImageSource = ImageSource.FromFile("icon_downloaded.png"); await Application.Current.MainPage.DisplayAlert("Success", "Notation successfully saved.", "OK"); } }