async void Delete(object sender, EventArgs e) { IFoodSpecialService _foodSpecService = Startup.Container.Get <IFoodSpecialService>(); var spec = (sender as MenuItem).BindingContext as FoodSpecial; await _foodSpecService.Delete(spec.SpecialId); _foodSpecials.Remove(spec); }
async void ManageSpec(object sender, EventArgs e) { var action = await DisplayActionSheet("Actions", "Cancel", "Delete", new string[] { "Edit", "Copy", "Report" }); switch (action) { #region Case Delete case "Delete": var confirm = await DisplayAlert("Delete", "Are you sure you want to delete " + _spec.Title + "?", "Yes", "No"); if (confirm) { UserDialogs.Instance.ShowLoading("Deleting", MaskType.Black); IFoodSpecialService _foodSpecService = Startup.Container.Get <IFoodSpecialService>(); await _foodSpecService.Delete(_spec.SpecialId); UserDialogs.Instance.HideLoading(); await Navigation.PopAsync(); } break; #endregion #region Case Edit case "Edit": var editFoodSpecPage = new AddEditFoodSpec(_restaurant, FoodSpecialActions.Edit, _spec); editFoodSpecPage.Disappearing += (send, args) => { SetFields(); }; await Navigation.PushModalAsync(editFoodSpecPage); break; #endregion } }