private async void DeleteItem(ToDoItem item) { var confirmPopup = new ConfirmationPopupPage() { Header = "Delete", Body = "Are you sure you want to delete this item?", ConfirmButtonText = "Yes" }; await _popupNavigation.PushAsync(confirmPopup); if (!await confirmPopup.Task) { return; } try { await _toDoService.DeleteItem(_list.Id, item.Id); Items.Remove(item); OnPropertyChanged(nameof(Items)); // To show/hide list } catch (Exception ex) { Debug.Fail("Error deleting item", ex.Message); } }
// GET: ToDoController/Delete/5 public ActionResult Delete(int id) { try { _toDoService.DeleteItem(id); return(RedirectToAction(nameof(Index))); } catch (Exception ex) { _logger.LogError(ex, "Произошла ошибка при попытке удалить сущность"); return(RedirectToAction("Edit", "ToDo", new { Id = id })); } }