private async Task OpenAddNewItemPage(ItemsWithRating item) { NewItemPage newItemPage = new NewItemPage(true, item.item); newItemPage.CallbackEvent += async(object sender, object e) => await NewItemPageCallbackMethod(); await Navigation.PushModalAsync(new NavigationPage(newItemPage)); }
private async void Delete_Tapped(object sender, EventArgs e) { FontIconLabel button = (FontIconLabel)sender; button.IsEnabled = false; try { ItemsWithRating item = (ItemsWithRating)((Label)sender).BindingContext; var answer = await DisplayAlert("Message", "Are you sure you want to delete item '" + item.item.foodName + "' ?", "YES", "NO"); if (answer) { DeleteItemByIdRequest reqObj = new DeleteItemByIdRequest() { id = item.item.id.ToString() }; var res = await userProfileViewModel.DeleteItemById(reqObj); if (res != null) { if (res.Code == 0) { await DisplayAlert("Message", "Item deleted successfully!", null, "OK"); await LoadUser(); viewModel.LoadItemsCommand.Execute(null); //viewModel.ExecuteLoadItemsCommand(); } else { await DisplayAlert("Message", "Couldn't delete the item. Please try again.", null, "OK"); } } else { await DisplayAlert("Message", "Couldn't delete the item. Please try again.", null, "OK"); } } } catch (Exception ex) { } finally { button.IsEnabled = true; } }
private async void Edit_Tapped(object sender, EventArgs e) { FontIconLabel button = (FontIconLabel)sender; button.IsEnabled = false; try { ItemsWithRating item = (ItemsWithRating)((Label)sender).BindingContext; await OpenAddNewItemPage(item); } catch (Exception ex) { } finally { button.IsEnabled = true; } }