public override bool OnOptionsItemSelected(IMenuItem item) { if (IsActive) { int id = item.ItemId; if (id == Android.Resource.Id.Home) { MainActivity.IsNavDisabled = false; Activity.OnBackPressed(); return(true); } else if (id == Resource.Id.view_restaurant) { Fragment fragment = RestaurantViewFragment.NewInstance(booking.RestaurantId); FragmentManager.BeginTransaction() .Replace(Resource.Id.content_frame, fragment) .AddToBackStack(null) .Commit(); } else if (id == Resource.Id.cancel_booking) { new Android.App.AlertDialog.Builder(Activity). SetIcon(Android.Resource.Drawable.IcDialogAlert). SetTitle("Confirm"). SetMessage("Are you sure you want to cancel the booking?"). SetPositiveButton("Yes", (c, ev) => { bool res = _bookingFacade.Cancel(booking.Id).Result; if (res) { Toast.MakeText(Activity, "Booking Cancelled", ToastLength.Long).Show(); Fragment fragment = BookingIndexFragment.NewInstance(); FragmentManager.BeginTransaction() .Replace(Resource.Id.content_frame, fragment) .Commit(); } else { Toast.MakeText(Activity, "An error occured whilst cancelling. Please try again later", ToastLength.Long).Show(); } }). SetNegativeButton("No", (c, ev) => { }). Show(); } } return(base.OnOptionsItemSelected(item)); }
public ActionResult CancelConfirmed(int id) { _bookingFacade.Cancel(id); return(RedirectToAction("Index", new { userId = Session[Global.UserIdSessionVar] })); }