示例#1
0
        private async void DeleteCategoryCommandHandler(object p)
        {
            // Confirm delete
            var res = await DialogHelper.Confirm("All items under this category will be deleted. Are you sure you want to delete this category?",
                                                 async (ap) =>
            {
                var category = p as ApiCategory;
                // Get the selected items and delete them
                if (category != null)
                {
                    try
                    {
                        // Delete the item
                        var success = await KryptPadApi.DeleteCategoryAsync(category.Id);

                        // If sucessful, remove item from the list
                        if (success)
                        {
                            // Refresh the view
                            await RefreshCategoriesAsync();
                        }
                    }
                    catch (WebException ex)
                    {
                        // Something went wrong in the api
                        await DialogHelper.ShowMessageDialogAsync(ex.Message);
                    }
                    catch (Exception ex)
                    {
                        // Failed
                        await DialogHelper.ShowGenericErrorDialogAsync(ex);
                    }
                }
            }
                                                 );
        }