コード例 #1
0
        private async void SetFavoriteCommandHandler(object obj)
        {
            var item = obj as ApiItem;

            try
            {
                // Remove favorite
                await KryptPadApi.DeleteItemFromFavoritesAsync(item);

                // Remove from list
                Items.Remove(item);

                // Update empty message
                if (Items.Count == 0)
                {
                    EmptyMessageVisibility = Visibility.Visible;
                }
            }
            catch (WebException ex)
            {
                // Something went wrong in the api
                await DialogHelper.ShowMessageDialogAsync(ex.Message);
            }
            catch (Exception ex)
            {
                // Failed
                await DialogHelper.ShowGenericErrorDialogAsync(ex);
            }
        }
コード例 #2
0
        private async void SetFavoriteCommandHandler(object obj)
        {
            var item = obj as ApiItem;

            try
            {
                // Set / remove favorite
                if (!item.IsFavorite)
                {
                    await KryptPadApi.AddItemToFavoritesAsync(item);
                }
                else
                {
                    await KryptPadApi.DeleteItemFromFavoritesAsync(item);
                }
            }
            catch (WebException ex)
            {
                // Something went wrong in the api
                await DialogHelper.ShowMessageDialogAsync(ex.Message);
            }
            catch (Exception ex)
            {
                // Failed
                await DialogHelper.ShowGenericErrorDialogAsync(ex);
            }
        }